fix(types): validate RFC 3339 timestamp and normalize to UTC in codecs - #656
Open
Varun-S10 wants to merge 1 commit into
Open
fix(types): validate RFC 3339 timestamp and normalize to UTC in codecs#656Varun-S10 wants to merge 1 commit into
Varun-S10 wants to merge 1 commit into
Conversation
🧪 Code CoverageNo coverage changes. Generated by coverage-comment.yml |
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
Thank you for opening a Pull Request!
Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
CONTRIBUTINGGuide.fix:which represents bug fixes, and correlates to a SemVer patch.feat:represents a new feature, and correlates to a SemVer minor.feat!:, orfix!:,refactor!:, etc., which represent a breaking change (indicated by the!) and will result in a SemVer major.Fixes #641 🦕
What was the bug?
In the A2A protobuf specification,
TaskStatus.timestampandListTasksRequest.status_timestamp_afterare typed asgoogle.protobuf.Timestamp. According to the proto3 JSON specification:+05:30or-05:00) must be normalized to UTC (Z).Previously,
TaskStatus.fromJSONandListTasksRequest.fromJSONpassed timestamp inputs straight through as raw strings usingglobalThis.String(object.timestamp)without validation or normalization:"not-a-timestamp","", or12345were accepted without error and forwarded downstream, causinga2a-pythonpeers to crash when receiving them."2026-01-01T05:30:00+05:30") were never converted to UTC ("2026-01-01T00:00:00Z"), leading to byte-level mismatches during card signing and canonicalization.How is it fixed?
src/types/pb/a2a.ts:fromJsonTimestamphelper that validates RFC 3339 date strings, throws a descriptive error on invalid inputs ("not-a-timestamp","",12345, boolean, object), and normalizes non-UTC timezone offsets to UTC (Z).TaskStatus.fromJSONandListTasksRequest.fromJSONto usefromJsonTimestamp.test/types/timestamp.spec.ts:Verification
TaskStatus.fromJSONandListTasksRequest.fromJSONthrow on malformed/empty/numeric timestamps."2026-01-01T00:00:00Z".test/types/timestamp.spec.tspassed (14/14).npm test) passed (69/69test files,1,501tests).npm run lint) passed with 0 errors.npm run build && npm run test-build) passed cleanly.