Add Spector case for serializing fractional duration encoded as integer#10835
Draft
Copilot wants to merge 2 commits into
Draft
Add Spector case for serializing fractional duration encoded as integer#10835Copilot wants to merge 2 commits into
Copilot wants to merge 2 commits into
Conversation
Co-authored-by: JoshLove-msft <54595583+JoshLove-msft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add Spector case for serializing duration as integer
Add Spector case for serializing fractional duration encoded as integer
May 29, 2026
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.
Existing
encode/durationscenarios only used whole-number payloads, so they couldn't catch the bug from #10831 where adurationwith a fractional sub-second component was serialized as a floating point number (e.g.123.45) instead of an integer.Changes (
packages/http-specs/specs/encode/duration/)main.tsp: Newint32-seconds-fractionalscenarios in theQuery,Property, andHeadernamespaces. Each constructs a35.625-second duration encoded asint32seconds:mockapi.ts: New handlers (createBodyIntServerTests,createQueryIntServerTests,createHeaderIntServerTests) assert the received value is an integer and reject floating point. Validation checks integer-ness rather than an exact value, since truncate-vs-round semantics across languages is still unresolved in the issue discussion — this verifies the core contract ("serializes as an int") without prescribing a rounding mode.spec-summary.md: Regenerated.Open question
The cross-language semantic for converting a fractional duration to an integer (truncate vs. round) remains undecided per the issue thread. The mock is intentionally lenient so it passes under either choice while still failing on float output; tightening to an exact value can follow once the semantic is settled.