fix: tolerate non-leading $type in polymorphic payloads (closes #50) #51

Merged
Grandiras merged 1 commit from fix/out-of-order-type-metadata into main 2026-07-25 02:03:27 +00:00
Owner

The Bluesky appview serializes embed views with the discriminator LAST
({"external": …, "$type": …}) and real-world record writers do the
same inside record unions — System.Text.Json needs
AllowOutOfOrderMetadataProperties for that. Set it in both
AtProtoJsonDefaults.Options and LexiconTypeRegistry.CreateOptions().
Fixes getPosts/getPostThread/timeline deserialization wherever a post
carries an embed. Regression tests with the captured appview shape.

Found by Mise's engagement hydration (anchor share-post resolution).

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

The Bluesky appview serializes embed views with the discriminator LAST ({"external": …, "$type": …}) and real-world record writers do the same inside record unions — System.Text.Json needs AllowOutOfOrderMetadataProperties for that. Set it in both AtProtoJsonDefaults.Options and LexiconTypeRegistry.CreateOptions(). Fixes getPosts/getPostThread/timeline deserialization wherever a post carries an embed. Regression tests with the captured appview shape. Found by Mise's engagement hydration (anchor share-post resolution). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
fix: tolerate non-leading $type in polymorphic payloads (closes #50)
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
8b88f97329
The Bluesky appview serializes embed views with the discriminator LAST
({"external": …, "$type": …}) and real-world record writers do the
same inside record unions — System.Text.Json needs
AllowOutOfOrderMetadataProperties for that. Set it in both
AtProtoJsonDefaults.Options and LexiconTypeRegistry.CreateOptions().
Fixes getPosts/getPostThread/timeline deserialization wherever a post
carries an embed. Regression tests with the captured appview shape.

Found by Mise's engagement hydration (anchor share-post resolution).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
Owner

@claude-bot Please fix the conflicts.

@claude-bot Please fix the conflicts.
Collaborator

🤖 On it — follow along in the action run; the reply will link the full session transcript.

🤖 On it — follow along in [the action run](https://git.grandiras.net/Grandiras/claude-bot/actions/runs/31); the reply will link the full session transcript.
claude-bot force-pushed fix/out-of-order-type-metadata from 8b88f97329
Some checks failed
CI / build-and-test (pull_request) Has been cancelled
to 24f529d1e1
Some checks failed
CI / build-and-test (pull_request) Successful in 39s
Sync Closures to GitHub / sync-closure (pull_request) Failing after 7s
2026-07-25 02:02:32 +00:00
Compare
Collaborator

Conflicts resolved — fix/out-of-order-type-metadata is now rebased onto main (669b851) and force-pushed.

The conflict was CHANGELOG-only. Both sides appended to ## [Unreleased] → ### Fixed: main had picked up the two OAuth handle-resolution entries from #52/#54, and this branch adds the #50 polymorphic-$type entry. I kept all of them, ordering the #50 bullet after the #52 entries and before the pre-existing Directory.Build.props bullet. No code files conflicted — the actual fix (AllowOutOfOrderMetadataProperties in AtProtoJsonDefaults.Options and LexiconTypeRegistry.CreateOptions()) and the regression tests replayed cleanly.

I rebased rather than merged so the PR stays a single commit (24f529d), matching the repo's one-commit-per-issue workflow.

Verified (had to install the .NET 10 SDK in the container first — it wasn't present):

  • dotnet build -p:EnableSourceControlManagerQueries=false0 errors; the 1160 warnings are pre-existing (CS1591 XML-doc gaps, one Razor RZ10012).
  • dotnet test tests/ATProtoNet.Tests/ -p:EnableSourceControlManagerQueries=false942 passed, 0 failed, 0 skipped.
  • OutOfOrderTypeMetadataTests specifically → 3 passed, so the captured appview shape still deserializes on top of the rebased main.

⏱ 1m 54s · 17 turns · tokens: 22.0k in / 3.7k out (+505.6k cache-read)
📜 Full session transcript

Conflicts resolved — `fix/out-of-order-type-metadata` is now rebased onto `main` (`669b851`) and force-pushed. **The conflict was CHANGELOG-only.** Both sides appended to `## [Unreleased] → ### Fixed`: `main` had picked up the two OAuth handle-resolution entries from #52/#54, and this branch adds the #50 polymorphic-`$type` entry. I kept all of them, ordering the #50 bullet after the #52 entries and before the pre-existing `Directory.Build.props` bullet. No code files conflicted — the actual fix (`AllowOutOfOrderMetadataProperties` in `AtProtoJsonDefaults.Options` and `LexiconTypeRegistry.CreateOptions()`) and the regression tests replayed cleanly. I rebased rather than merged so the PR stays a single commit (`24f529d`), matching the repo's one-commit-per-issue workflow. **Verified** (had to install the .NET 10 SDK in the container first — it wasn't present): - `dotnet build -p:EnableSourceControlManagerQueries=false` → **0 errors**; the 1160 warnings are pre-existing (CS1591 XML-doc gaps, one Razor RZ10012). - `dotnet test tests/ATProtoNet.Tests/ -p:EnableSourceControlManagerQueries=false` → **942 passed, 0 failed, 0 skipped**. - `OutOfOrderTypeMetadataTests` specifically → **3 passed**, so the captured appview shape still deserializes on top of the rebased `main`. --- ⏱ 1m 54s · 17 turns · tokens: 22.0k in / 3.7k out (+505.6k cache-read) 📜 [Full session transcript](https://git.grandiras.net/Grandiras/claude-bot/src/branch/claude-logs/transcripts/Grandiras/ATProto.NET/issue-51/run-31.md)
Grandiras deleted branch fix/out-of-order-type-metadata 2026-07-25 02:03:27 +00:00
Sign in to join this conversation.
No description provided.