-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Dag object that could be read in 0.4.17 can no longer be read in 0.4.18 #5776
Comments
Upstream bug report: polydawn/refmt#43 |
So, it looks like you ended up encoding |
This is a js app that is using go-ipfs as storage and uses it via the REST api on port 5001. Due to various issues (very long story) we transitioned from using the dag api of go-ipfs to doing the conversion from JSON to CBOR inside javascript and using the block api. So here is the code I am using: import * as dagCbor from 'ipld-dag-cbor'
const encode = <T>(value: T): Observable<Buffer> =>
new Observable<Buffer>(subscriber => {
dagCbor.util.serialize(value, (err: any, serialized: Buffer) => {
if (err !== null) {
subscriber.error(err)
} else {
subscriber.next(serialized)
subscriber.complete()
}
})
}) from package.json:
|
So for whatever reason I got a js object which is The cbor encoder should either refuse to encode this at all (which would be very inconvenient but at least clear), or should treat
Instead borc uses some guard value for "can not encode this", which yields incorrect CBOR. Is that a correct summary? |
Not quite. borc encoded JavaScript's undefined to CBOR's undefined; the final output is technically "valid" CBOR. However, CBOR's undefined is really only supposed to be used to indicate a failure to encode so users can partially encode values. It's not meant to be equivalent to JavaScript's undefined. Spec:
|
See: ipfs/kubo#5776 This won't round-trip undef, it'll just convert it to null (which is what most decoders do anyways).
(fixed) |
Version information:
$ ipfs version --all
go-ipfs version: 0.4.18-
Repo version: 7
System version: amd64/darwin
Golang version: go1.11.1
Type:
Bug
Description:
A block that could be read as using
ipfs dag get
in versions up to 0.4.17 no longer can be read as as a dag object in 0.4.18.Before:
After:
The block:
hexdump
base64
The text was updated successfully, but these errors were encountered: