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

未关闭 适合新手
#2,940 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
88/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
bun, node.js, typescript
领域
cli, observability

调研方向

从 src/handlers/observability/time.ts 中的 parseTimeString 开始,检查纯数字字符串在传递给 Date.parse 之前是如何处理的。添加拒绝不支持的纯数字并显示预期的无效时间提示的逻辑,然后运行相关的 logs 和 traces 测试。完成标准是:5、60 和 45 等值会产生无效时间错误,同时受支持的格式仍能正常工作。

由索引模型根据 Issue 内容生成。

描述

Description

--since / --until on the logs and traces commands accept 5m, 1h, ISO 8601, epoch ms or
now. A bare number shorter than 13 digits is not rejected: parseTimeString
(src/handlers/observability/time.ts) passes it to Date.parse, which reads it leniently as a
calendar date. So a forgotten unit turns into a window decades long, or a confusing error.

Steps to Reproduce
  1. agentcore runtime logs --id <runtime-id> --since 5 (meant 5m).
  2. agentcore runtime logs --id <runtime-id> --since 60.
  3. agentcore runtime logs --id <runtime-id> --since 45.
Expected Behavior

Invalid time string: "5". Use relative durations (5m, 1h, 2d), ISO 8601, epoch ms, or "now".

Actual Behavior
  1. Searches from 2001-05-01 (Date.parse("5")).
  2. Searches from 1960-01-01.
  3. Fails with --since must resolve to a time before --until ("45" is 2045-01-01).

("30" happens to be rejected, because V8 cannot parse it.)

CLI Version

1.2.0 (current v1.x, a6452a4)

Operating System

Linux

Additional Context

Same under Node 22 and Bun 1.4 (the npm bundle and the compiled binaries).

主要语言
TypeScript
星标
339
派生
129
平均合并
19 小时 21 分钟
30 天内合并 PR
125

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

aws/agentcore-cli 的其他 Issue

查看 aws/agentcore-cli 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。