Skip to content

fix: accept a plain number of seconds as a duration - #1164

Merged
hsablonniere merged 1 commit into
masterfrom
davlgd-fix-duration-seconds
Sep 25, 2026
Merged

hsablonniere merged 1 commit into
masterfrom
davlgd-fix-duration-seconds

Conversation

@davlgd

@davlgd davlgd commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Closes #1163

Context

A plain number of seconds passed to --after or --before becomes an invalid date: clever logs shows no logs without any error.

Proposal

  • parseSimpleDuration() throws when there is no known unit, so the fallback on a number of seconds is reached
  • This fallback only accepts digits, so 10x is rejected instead of read as 10 seconds

How to test

clever logs --after 3600 --before 1s   # before: no logs, after: logs of the last hour
clever logs --after 10x                # before: no logs, after: "Invalid duration" error
clever logs --after 1h --before 1s     # unchanged

@davlgd
davlgd requested a review from a team as a code owner September 24, 2026 17:39
@github-actions

github-actions Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🔎 The preview has been automatically deleted.

@pdesoyres-cc pdesoyres-cc left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@hsablonniere hsablonniere left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looked into whether this could be expressed more declaratively with Zod (a union of duration/date schemas). It's feasible, but the rest of the codebase isn't there yet (still JS, not TypeScript). Once we're fully on TypeScript, moving this kind of parsing/validation logic to Zod schemas will be worth revisiting.

Approving as is.

@hsablonniere
hsablonniere force-pushed the davlgd-fix-duration-seconds branch from 8cbedd7 to 2f7426a Compare September 25, 2026 09:10
@hsablonniere
hsablonniere merged commit cb02fc0 into master Sep 25, 2026
6 checks passed
@hsablonniere
hsablonniere deleted the davlgd-fix-duration-seconds branch September 25, 2026 09:13
@hsablonniere hsablonniere added this to the 5.1.0 milestone Sep 25, 2026
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.

A plain number of seconds is not accepted as a duration

3 participants