Non-Canonical varints in CIDs #2191
Replies: 3 comments 3 replies
-
(after deleting the record containing the invalid CID, my repo is syncing again) This record value should reproduce the issue: {
"$type": "app.bsky.feed.post",
"createdAt": "2024-02-19T12:47:18.827Z",
"text": "test",
"langs": [
"en"
],
"secret": {
"foo": {
"$link": "bqgaabaeaacaiaaeaqaaa"
}
}
} |
Beta Was this translation helpful? Give feedback.
-
I think it's probably uncontroversial what to do about non-minimal varints, but what's perhaps less clear is whether software should even be trying to validate CIDs within records in the first place. Maybe the PDS's behavior here is overall more sensible. The CID spec defines v0 and v1 formats, with v2 and v3 "reserved" but otherwise unspecified. You obviously can't validate a v2 or v3 CID today, so should they be rejected, at the risk of breaking compatibility with future software? |
Beta Was this translation helpful? Give feedback.
-
This is a great little interoperability case study:
These are more questions than answers right now. Some related work-in-flight: |
Beta Was this translation helpful? Give feedback.
-
The reference PDS implementation accepts records containing
$link
CIDs containing non-canonical varint encodings, whereas the spec requires them to be minimally encoded.This looks like a bug/oversight in js-multiformats: https://github.com/multiformats/js-multiformats/blob/dcbd5d73d80da321c8ee64a648ded51199d731bb/src/vendor/varint.js#L44-L69 (side-note, this impl will also happily overflow JS's precision limits, resulting in loss of precision and/or NaNs)
On the other hand, it looks like the Relay implementation correctly(?) rejects them as invalid. This divergence means that commits to my repo no longer reach the AppView. Oops!
Beta Was this translation helpful? Give feedback.
All reactions