Skip to content

Duration parsing accepts zero values, data expires immediately #338

@umag

Description

@umag

Description

In src/domain/data/data_lifecycle_service.ts (lines 337-341), parseDuration() accepts zero values like "0h", "0d", "0w" which produce 0 milliseconds. The LifetimeSchema regex /^\d+(mo|y|h|m|d|w)$/ also matches these. Data configured with a zero lifetime expires immediately on creation.

Steps to Reproduce

  1. Create data with lifetime "0h" — passes schema validation
  2. The data expires immediately (expiration = creation time + 0ms)
  3. GC deletes the data on next scan

Expected Behavior

Zero durations should be rejected by the schema validation. The regex should require at least 1 for the numeric part.

Actual Behavior

"0h", "0m", "0d", "0w", "0mo", "0y" all pass validation and produce 0ms duration.

Summary

This affects duration parsing in the data lifecycle service. The fix would involve changing the regex to /^[1-9]\d*(mo|y|h|m|d|w)$/ or adding a post-parse check that the numeric value is > 0.

Metadata

Metadata

Assignees

Labels

awaiting-feedbackWaiting on further inputbugSomething isn't workingexternalAn issue raised by an external contributor

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions