Commit 92a2b39
fix(pds): normalize JSON blob refs for correct dag-cbor encoding (#119)
* fix(pds): normalize JSON blob refs for correct dag-cbor encoding
Incoming API records contain blob references with nested $link objects
(e.g. { "$type": "blob", "ref": { "$link": "bafk..." } }). Without
normalization, @atproto/repo's lexToIpld walks these as plain objects,
encoding the ref as a CBOR map instead of a CID tag. This produces
incorrect block hashes that cause blob resolution failures downstream.
Add normalizeRecordLinks() to convert $link → CID and $bytes →
Uint8Array before records hit repo.applyWrites(). Applied on all
write paths: createRecord, putRecord, applyWrites.
Also handle Uint8Array → $bytes serialization on the read path.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: use @atproto/lexicon jsonToLex instead of hand-rolled normalization
Replace the custom normalizeRecordLinks implementation with a re-export
of jsonToLex from @atproto/lexicon. This is better because:
- Battle-tested against edge cases the custom impl may miss
- Also converts blob refs to proper BlobRef instances (not just CIDs)
- One line instead of 75
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: use jsonToLex directly instead of format.ts alias
Import jsonToLex from @atproto/lexicon directly in account-do.ts instead of
re-exporting it as normalizeRecordLinks from format.ts. Removes the
unnecessary alias and the test file that was just testing library behavior.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* refactor: use @atproto/lex-json directly, remove @atproto/lexicon dep
* fix: regenerate lockfile without spurious dep resolution changes
The previous lockfile bumped @atproto/common-web from 0.4.7 to 0.4.8
inside @atproto/lexicon, which likely caused CI test failures in
vitest-pool-workers. Reset from main and cleanly added only
@atproto/lex-json.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* test(pds): add blob ref normalization integration tests
Verifies that JSON-serialized blob refs ({"$link": "..."}) are properly
normalized to CID objects when stored in the repo via createRecord,
putRecord, and applyWrites. Uses raw repo access to confirm internal
representation matches expectations.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Lock freshen
* Use vitest beta
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 82301c5 commit 92a2b39
File tree
7 files changed
+1588
-1380
lines changed- .changeset
- packages
- oauth-provider
- pds
- src
- test
7 files changed
+1588
-1380
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
26 | 32 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| 37 | + | |
37 | 38 | | |
38 | 39 | | |
39 | 40 | | |
| |||
59 | 60 | | |
60 | 61 | | |
61 | 62 | | |
62 | | - | |
| 63 | + | |
63 | 64 | | |
64 | 65 | | |
65 | 66 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| |||
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
333 | | - | |
| 334 | + | |
334 | 335 | | |
335 | 336 | | |
336 | 337 | | |
| |||
471 | 472 | | |
472 | 473 | | |
473 | 474 | | |
| 475 | + | |
474 | 476 | | |
475 | 477 | | |
476 | 478 | | |
477 | 479 | | |
478 | 480 | | |
479 | | - | |
| 481 | + | |
480 | 482 | | |
481 | 483 | | |
482 | 484 | | |
483 | 485 | | |
484 | 486 | | |
485 | | - | |
| 487 | + | |
486 | 488 | | |
487 | 489 | | |
488 | 490 | | |
| |||
581 | 583 | | |
582 | 584 | | |
583 | 585 | | |
584 | | - | |
| 586 | + | |
585 | 587 | | |
586 | 588 | | |
587 | 589 | | |
| |||
598 | 600 | | |
599 | 601 | | |
600 | 602 | | |
601 | | - | |
| 603 | + | |
602 | 604 | | |
603 | 605 | | |
604 | 606 | | |
| |||
1528 | 1530 | | |
1529 | 1531 | | |
1530 | 1532 | | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
1531 | 1542 | | |
1532 | 1543 | | |
1533 | 1544 | | |
| |||
0 commit comments