Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fails to decode a valid CBOR object #43

Closed
Stebalien opened this issue Nov 14, 2018 · 2 comments · Fixed by #44
Closed

Fails to decode a valid CBOR object #43

Stebalien opened this issue Nov 14, 2018 · 2 comments · Fixed by #44

Comments

@Stebalien
Copy link
Contributor

Specifically (base64 encoded):

pWNtYXgYGmNtaW4AZHByZXb3ZWJsb2Nr2CpYJQABcRIgnFmrwDoxE64kVL5FW13qCRd7b2Ik1wiT
53QXBnkSmNtlaW5kZXiic2VkZ2UuYXguc2YuVGVybWluYWyBa3RoZVRlcm1pbmFsdGVkZ2UuYXgu
c2YuVWlTZXNzaW9ugmg0RTgxNUU2M2lTb21lIEJvZHk=

This should decode to (python syntax):

{'max': 26, 'min': 0, 'prev': None, 'block': Tag(42, b'\x00\x01q\x12 \x9cY\xab\xc0:1\x13\xae$T\xbeE[]\xea\t\x17{ob$\xd7\x08\x93\xe7t\x17\x06y\x12\x98\xdb'), 'index': {'edge.ax.sf.Terminal': ['theTerminal'], 'edge.ax.sf.UiSession': ['4E815E63', 'Some Body']}}

Error:

Error: Invalid majorByte: 0xf7

Test case:

On go-ipfs 0.4.18, run: ipfs dag get zdpuArHM9moUGtzo47sHeQ5qS4jiuQApyMnFFLoBDdYeouwHy

Downstream bug ipfs/kubo#5776.

@Stebalien
Copy link
Contributor Author

Looks like this is the undefined type. According to the spec, it looks like that should be used to indicate encoding errors... WHY? 😭

It looks like we're not the first to trip over this: FasterXML/jackson-dataformats-binary#93

I'm going to suggest the same solution: silently coerce to null (maybe we should make that optional)?

Stebalien added a commit to Stebalien/refmt that referenced this issue Nov 14, 2018
Bleh. We're not going to round-trip this but we shouldn't hit this anyways.

Alternatively, we could just return an error. However, that may break things for
some users...

fixes polydawn#43
@warpfork
Copy link
Member

cbor.DecodeOptions{CoerceUndefToNull:true} is now supported 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants