-
-
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
Extra newline at end of "dag get" result #3503
Comments
JSON isn't a stable format, we have no way of knowing was was the initial format of the json you have passed in. Also you are passing it in with a new line, but doing |
ipfs dag put --help says that the default input format is JSON. |
Yes, input format is JSON but storage format is CBOR, which is stable format.
There are infinitely many ways you can store same data in JSON ( If you want to store the white-space information, use plain |
@djdv I tried the printf suggestion, but, as Jakub predicted, it gives the same result. @Kubuxu I get that JSON -> CBOR is many to one, and you need some canonical format. What I don't get is why that canonical format has a newline outside a minimal form of the json. As a consumer of the api, even one who is well versed in other aspects of IPFS this is surprising to me. (Also, I originally submitted this after discussing it with @whyrusleeping) |
Yeah, the primary issue here isnt that the input object differs from the output object, the problem is that theres a newline after the json blob for some reason. |
Verified this is still an issue in 0.5 |
For the record, this is still an issue in 0.9.0. |
This may get resolved in the refactoring of |
Write a `sharness` test that expects failure documenting the issue raised in #3503. The issue may get resolved in the refactoring of `ipfs dag get` command to support go-ipld-prime (e.g. #8171). For now add a `sharness` test that expects failure. We will then flip the expectation in the success in the rewriting PR to check if #3503 gets resolved. Relates to: - #3503
Add test with expected failure for #3503
@aschmahmann I can confirm #7995 fixes this issue. |
Great, we'll close this issue out once it's been incorporated into master. |
* feat: switch to using go-ipld-prime for codecs, path resolution, and the `dag put/get` commands * fix: `dag put/get` not roundtripping due to an extra new line being added (#3503) More detailed information is in the CHANGELOG.md file. Very high level: * IPLD codecs (and their plugins) must use go-ipld-prime * Added support for the dag-json codec * `dag get/put` use IPLD codec names from the multicodec table * `dag get` defaults to dag-json output instead of json, but may output with other codecs * Data model pathing can be achieved using the /ipld prefix. For example, you can use `/ipld/QmFoo/Links/0/Hash` to traverse through a DagPB node * With `dag get/put` the DagPB field names have been changed to match the ones in the protobuf listed in the specification Co-authored-by: hannahhoward <hannah@hannahhoward.net> Co-authored-by: Daniel Martí <mvdan@mvdan.cc> Co-authored-by: acruikshank <acruikshank@example.com> Co-authored-by: Steven Allen <steven@stebalien.com> Co-authored-by: Will Scott <will.scott@protocol.ai> Co-authored-by: Will Scott <will@cypherpunk.email> Co-authored-by: Rod Vagg <rod@vagg.org> Co-authored-by: Adin Schmahmann <adin.schmahmann@gmail.com> Co-authored-by: Eric Myhre <hash@exultant.us>
Closing since it's in RC |
* feat: switch to using go-ipld-prime for codecs, path resolution, and the `dag put/get` commands * fix: `dag put/get` not roundtripping due to an extra new line being added (ipfs/kubo#3503) More detailed information is in the CHANGELOG.md file. Very high level: * IPLD codecs (and their plugins) must use go-ipld-prime * Added support for the dag-json codec * `dag get/put` use IPLD codec names from the multicodec table * `dag get` defaults to dag-json output instead of json, but may output with other codecs * Data model pathing can be achieved using the /ipld prefix. For example, you can use `/ipld/QmFoo/Links/0/Hash` to traverse through a DagPB node * With `dag get/put` the DagPB field names have been changed to match the ones in the protobuf listed in the specification Co-authored-by: hannahhoward <hannah@hannahhoward.net> Co-authored-by: Daniel Martí <mvdan@mvdan.cc> Co-authored-by: acruikshank <acruikshank@example.com> Co-authored-by: Steven Allen <steven@stebalien.com> Co-authored-by: Will Scott <will.scott@protocol.ai> Co-authored-by: Will Scott <will@cypherpunk.email> Co-authored-by: Rod Vagg <rod@vagg.org> Co-authored-by: Adin Schmahmann <adin.schmahmann@gmail.com> Co-authored-by: Eric Myhre <hash@exultant.us>
Version information:
go-ipfs version: 0.4.5-dev-4cb236c
Repo version: 4
System version: amd64/linux
Golang version: go1.7.1
Type:
Bug
Priority:
P1 (for me)
Description:
Using either the cli or http api the dag get command seems to add an extra newline 0x0A on the end of the raw data.
To reproduce using cli:
then
ipfs dag get zdpuAs3whHmb9T1NkHSLGF45ykcKrEBxSLiEx6YpLzmKbQLEB | wc -c
should give 13, but gives 14, and the extra byte on the end is a newline
The same JSON through the http api results in the same extra byte. The JSON is not special, similar JSON with more/different elements does the same.
The text was updated successfully, but these errors were encountered: