Repository navigation
fix(observability): reject a --since/--until number that has no unit - #2957
Open
andretorresdg wants to merge 1 commit into
Open
andretorresdg wants to merge 1 commit into
andretorresdg wants to merge 1 commit into
Conversation
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.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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'sDate.parsereads short barenumbers as calendar dates:
"5"is 2001-05-01,"60"is 1960-01-01,"45"is 2045-01-01. So--since 5with a forgotten unit silently searches from 2001, and--since 45fails with theconfusing
--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-01still works. Happy to allowexactly 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
Testing
How have you tested the change?
bun test(full suite: 5106 pass, 0 fail; affected suites re-run on the latestv1.x)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
bun run typecheckbun run lint:checkbun run format:checkbun run auditbun run secrets:check(on the changed files)bun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed themby this PR
command.md(the release workflow regenerates it)The new case in
time.test.tsfails without the fix (Received value: 988675200000for"5") andpasses with it. The logs/traces handler suites still pass.
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.