Skip to content

fix(observability): reject a --since/--until number that has no unit - #2957

Open
andretorresdg wants to merge 1 commit into
aws:v1.xfrom
andretorresdg:time-bare-number
Open

andretorresdg wants to merge 1 commit into
aws:v1.xfrom
andretorresdg:time-bare-number

Conversation

@andretorresdg

Copy link
Copy Markdown
Contributor

Description

parseTimeString (shared by the logs and traces commands for --since / --until) treats 13+
digit numbers as epoch ms and hands anything else to Date.parse. V8's Date.parse reads short bare
numbers as calendar dates: "5" is 2001-05-01, "60" is 1960-01-01, "45" is 2045-01-01. So
--since 5 with a forgotten unit silently searches from 2001, and --since 45 fails with the
confusing --since must resolve to a time before --until.

A string of digits that is not epoch ms is now rejected with the existing
Invalid time string: "...". Use relative durations (5m, 1h, 2d), ISO 8601, epoch ms, or "now".
message. The documented formats are unchanged. One side effect: a bare 4-digit ISO year
(--since 2026) was accepted before and is now rejected; 2026-01-01 still works. Happy to allow
exactly four digits if you prefer to keep that form.

Related Issue

Closes #2940

Documentation PR

Not applicable. The flag descriptions already list the accepted formats.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update
  • Other (please describe):

Testing

How have you tested the change?

  • I ran bun test (full suite: 5106 pass, 0 fail; affected suites re-run on the latest v1.x)
  • I ran the relevant end-to-end tests with bun run test:e2e, or explained why they are not applicable
    (CI does not run them for you) — not run: no AWS credentials here; the change is flag validation
    before any AWS call
  • I ran bun run typecheck
  • I ran bun run lint:check
  • I ran bun run format:check
  • I ran bun run audit
  • I ran bun run secrets:check (on the changed files)
  • I ran bun run build
  • If I modified src/assets/, I updated affected snapshots with bun test <test-file> --update-snapshots and committed them
  • If I re-recorded fixtures or golden files, every change beyond account identifiers is explained
    by this PR
  • This PR does not change command.md (the release workflow regenerates it)

The new case in time.test.ts fails without the fix (Received value: 988675200000 for "5") and
passes with it. The logs/traces handler suites still pass.

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.

parseTimeString handed a bare number shorter than epoch ms to Date.parse,
which reads it leniently as a calendar date: `--since 5` (a forgotten
unit) searched from 2001-05-01 and `--since 60` from 1960. Reject such
values with the existing "Invalid time string" guidance.
@andretorresdg
andretorresdg requested a review from a team November 28, 2026 18:05
@github-actions github-actions Bot added the size/xs PR size: XS label Nov 28, 2026

This branch has not been deployed

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

Labels

size/xs PR size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

logs/traces: --since 5 (missing unit) silently searches from 2001

1 participant