Skip to content

fix(functions): refuse a time string add_time_to_date cannot read - #6779

Open
chiruu12 wants to merge 1 commit into
keephq:mainfrom
chiruu12:fix/add-time-to-date-silent-noop
Open

fix(functions): refuse a time string add_time_to_date cannot read#6779
chiruu12 wants to merge 1 commit into
keephq:mainfrom
chiruu12:fix/add-time-to-date-silent-noop

Conversation

@chiruu12

@chiruu12 chiruu12 commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes #6778

add_time_to_date reads units with re.findall(r"(\d+)([wdhms])", time_str) and adds what it finds. When it finds nothing it adds nothing, so a string it cannot read returns the date unchanged and looks like it worked.

This raises instead. The message names the string it could not read and the units it understands.

Nothing that parsed before changes. 1w, 2d, 3h, 30m, 45s and 1w 2d 3h 30m all still work; the guard fires only when the regex matched nothing at all, which is why the spaced form is unaffected.

Tests cover six unreadable spellings, including 1y and 3M, which are the units people reach for and neither of which is supported. Three more pin the accepted forms as controls. The six fail on the commit before the fix and the three pass either way.

tests/test_functions.py tests/test_iohandler.py: 206 passed. ruff check clean.

I did not add month support. m already means minutes, so 3M cannot be a month without making the unit ambiguous. This is about the silence, not the unit set.

Copilot AI lite review requested due to automatic review settings September 7, 2026 21:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: keep.add_time_to_date silently returns the input date when it cannot read the time string

2 participants