Skip to content

fix(core): let a bare 4-digit ISO year parse in MessagingTemplate.parseTime - #701

Merged
dezren39 merged 1 commit into
mainfrom
queue/1776-695-parsetime-year
Oct 28, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/1776-695-parsetime-year

Conversation

@dezren39

@dezren39 dezren39 commented Oct 28, 2026 •

Copy link
Copy Markdown

Fixes #695.

What changed

MessagingTemplate.parseTime rejected every bare-digit string that was not exactly 10 or 13 digits, so a bare 4-digit ISO year ("2026") returned undefined and callers raised Invalid time. Before #623 (for #592) that form fell through to Date.parse and parsed as 2026-01-01.

A bare 4-digit year is now exempted from the bare-digit catch-all so it reaches the existing calendar-checked ModelRouteLimits.parseAbsoluteTime path — restoring the pre-#623 behaviour for the ISO year form only.

Behaviour

Input Result
2026 Date.parse("2026") -> 2026-01-01T00:00:00.000Z
10 digits epoch seconds -> ms (#592, unchanged)
13 digits epoch milliseconds (#592, unchanged)
9/11/12/14+ digits undefined (#592, unchanged)

The schema description in packages/schema/src/messaging.ts still matches (since = ISO time, relative age such as 2h or 3d, or a bare epoch), so no schema change.

Test

Added a regression test in packages/core/test/messaging-template.test.ts beside the existing bare-epoch cases:

test("a bare 4-digit ISO year parses as Jan 1 via Date.parse", () => {
  expect(MessagingTemplate.parseTime("2026", now)).toBe(Date.parse("2026"))
})

Verification (laptop)

  • bun test test/messaging-template.test.ts test/tool-messaging.test.ts test/messaging.test.ts -> 39 pass, 0 fail
  • bun typecheck in packages/core -> clean

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

…seTime

PR #623 rejected every bare-digit string that was not exactly 10 or 13 digits, so a bare ISO year such as "2026" returned undefined and callers raised Invalid time. Before #623 that form fell through to Date.parse and parsed as Jan 1.

Exempt a 4-digit bare year from the catch-all so it reaches the calendar-checked parseAbsoluteTime path. 10-digit epoch seconds, 13-digit epoch milliseconds, and every other bare-digit length keep their #592 behaviour.

Fixes #695
@coderabbitai

coderabbitai Bot commented Oct 28, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 53 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: dfe0395d-2654-4bc4-8a5f-98b80812319b
Commits

Reviewing files that changed from the base of the PR and between b1d8160 and 422d287.

Files selected for processing: 2
  • packages/core/src/messaging/template.ts
  • packages/core/test/messaging-template.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T09:57:31.860585Z 422d287 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions

Copy link
Copy Markdown

The following comment was made by an LLM, it may be inaccurate:

@dezren39
dezren39 merged commit ffd43a3 into main Oct 28, 2026
13 of 17 checks passed
@dezren39
dezren39 deleted the queue/1776-695-parsetime-year branch November 1, 2026 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(core): MessagingTemplate.parseTime regression in PR #623 — a bare ISO year ('2026') is now rejected instead of parsing as Jan 1

1 participant