Skip to content

fix: fix dictionary deserialization crash for specs with example values#10109

Merged
jorgerangel-msft merged 1 commit intomicrosoft:mainfrom
JoshLove-msft:fix/dict-deserialization-crash
Mar 20, 2026
Merged

fix: fix dictionary deserialization crash for specs with example values#10109
jorgerangel-msft merged 1 commit intomicrosoft:mainfrom
JoshLove-msft:fix/dict-deserialization-crash

Conversation

@JoshLove-msft
Copy link
Contributor

The dictionary TryReadComplexType overload (added in #9983) manually iterated dictionary entries but treated \ metadata as regular dictionary keys. When a dictionary value object contains \ (for reference tracking), the manual iteration read it as a dictionary entry key and tried to parse the reference ID string as an InputExampleValue, corrupting the reader position.

Fix: skip \ metadata entries (via TryReadReferenceId) when iterating dictionary keys, consistent with how other converters handle reference tracking metadata. This preserves the manual iteration needed to handle $-prefixed user keys (like ) while correctly ignoring serialization metadata.

Fixes regression from #9983.

The dictionary TryReadComplexType overload (added in microsoft#9983) manually
iterated dictionary entries but treated \ metadata as regular
dictionary keys. When a dictionary value object contains \ (for
reference tracking), the manual iteration read it as a dictionary
entry key and tried to parse the reference ID string as an
InputExampleValue, corrupting the reader position.

Fix: skip \ metadata entries (via TryReadReferenceId) when iterating
dictionary keys, consistent with how other converters handle reference
tracking metadata. This preserves the manual iteration needed to handle
\$-prefixed user keys (like \) while correctly ignoring
serialization metadata.

Fixes regression from microsoft#9983.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp label Mar 20, 2026
@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 20, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http-client-csharp@10109

commit: af7f283

@github-actions
Copy link
Contributor

No changes needing a change description found.

@jorgerangel-msft jorgerangel-msft added this pull request to the merge queue Mar 20, 2026
Merged via the queue into microsoft:main with commit efe6d40 Mar 20, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:csharp Issue for the C# client emitter: @typespec/http-client-csharp

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants