Skip to content

[NOT-STREAM] fix(python): encode a WIT duration in a JSON model - #65

Closed
moetemp wants to merge 3 commits into
moe/up/python-client-resourcesfrom
moe/up/python-json-duration
Closed

moetemp wants to merge 3 commits into
moe/up/python-client-resourcesfrom
moe/up/python-json-duration

Conversation

@moetemp

@moetemp moetemp commented Oct 23, 2026

Copy link
Copy Markdown
Owner

What changed?

This PR gives each Python model of a WIT-only record that holds a duration, at any depth, a transfer type converter. It encodes the timedelta as a proto3 JSON duration, such as "1.5s", and decodes it back.

Why?

The SDK JSON converter can't encode a timedelta, so a call with a duration set failed with "Object of type timedelta is not JSON serializable".

How did you test it?

The stream-service sample's read-records takes wait: option<duration> again, in place of wait-ms. The models.py golden shows the converter on CreateStreamRequest and ReadRecordsRequest. The long-poll sample test now sends a timedelta wait on each page through the data converter.

Open question: TypeScript sends common.Duration as the caller gives it (a string such as "1.5s" or a number of milliseconds), and .NET sends System.TimeSpan in the System.Text.Json form ("00:00:01.5000000"). The two disagree, so this PR uses the proto3 form, which TypeScript strings such as "1.5s" match.

Based on fork PR #57.

@moetemp moetemp changed the title [UPSTREAM-14] fix(python): encode a WIT duration in a JSON model [NOT-STREAM] fix(python): encode a WIT duration in a JSON model Oct 23, 2026
@moetemp

moetemp commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Closed as NOT-STREAM. Every streaming duration is in a proto-backed record, so it never goes through the JSON converter.

@moetemp moetemp closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant