Accept the data model's unpadded base64 in $bytes#48
Merged
Conversation
Synthesized Codable used JSONDecoder's .base64 Data strategy, which requires padding the atproto data model omits — so records re-serialized by a spec-compliant PDS (e.g. blacksky's rsky) failed to decode whenever the byte length wasn't a multiple of 3. Decode now tolerates both forms and encoding emits the spec's unpadded form. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: d2d0807 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Move the padding tolerance off Bytes' init(from:) onto the decoder: JSONDecoder.atproto (dataDecodingStrategy .atprotoBase64) accepts the data model's unpadded form for EVERY Data field, not just $bytes, and XRPC response parsing reads through it. A default JSONDecoder keeps Foundation's strict behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
The atproto data model serializes bytes as base64 without padding, but response decoding used JSONDecoder's default
.base64Data strategy, which rejects unpadded input. Any PDS that stores records as CBOR re-emits bytes unpadded (verified against both blacksky's rsky and bsky's own PDS), so records failed to decode whenever the byte length wasn't a multiple of 3; lengths that align to 4 base64 chars (e.g. a 33-byte anchor key) worked by luck, which made the failure look intermittent. The dual-slot PQ keyPackage (~3.4 KB) always lands on the misaligned case.The tolerance is a decoder option, not a property of the type:
JSONDecoder.atproto(viadataDecodingStrategy.atprotoBase64) accepts both unpadded (spec) and padded (previously written) forms for everyDatafield, and XRPC response parsing reads through it; a defaultJSONDecoderkeeps Foundation's strict behavior.Atproto.Primitive.Bytesencodes the spec's unpadded form. Includes a changeset (patch). App-side counterpart: germ-network/germDM-ios-refresh#497.🤖 Generated with Claude Code