-
Notifications
You must be signed in to change notification settings - Fork 298
Conversation
Found this very strange bug when creating DAGNode's with empty buffers for data. streamToValue returns an empty array when the data is empty, which down the line triggers an exception in ipfs-block because this sends an empty array instead of a buffer.
Thanks @mikeal, do you have a sec to add a test for this to |
Hrm... that will take some time. There's a lot of test framework and fixtures to figure out in those tests that I have no experience with. I can do it, but I won't find the time for a while. |
This PR allows the test in ipfs-inactive/interface-js-ipfs-core#308 to pass. X-Stream-Output header is added to block.get reply for parity with go-ipfs. block.put is altered to allow an empty block to be put (again for fetaure parity with go-ipfs) but only if there is a multipart file part for it. Error responses have also been improved. refs ipfs-inactive/js-ipfs-http-client#789 tested by ipfs-inactive/interface-js-ipfs-core#308 License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
js-ipfs currently does not set the X-Stream-Output header on block.get responses so we also need a check for an empty array on our buffered res. License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
I've amended this to add the same check for when the response doesn't have the go-ipfs currently sets this (which is why we drop into the I added a test for this (ipfs-inactive/interface-js-ipfs-core#308) and verified that it doesn't work before your fix and it does work after. Hoorays \o/ There's also a PR against js-ipfs (ipfs/js-ipfs#1408) to add the Phew, fun times. |
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Failing tests are unrelated and possibly due to ipfs/kubo#5146
* fix: allow put empty block & add X-Stream-Output header on get This PR allows the test in ipfs-inactive/interface-js-ipfs-core#308 to pass. X-Stream-Output header is added to block.get reply for parity with go-ipfs. block.put is altered to allow an empty block to be put (again for fetaure parity with go-ipfs) but only if there is a multipart file part for it. Error responses have also been improved. refs ipfs-inactive/js-ipfs-http-client#789 tested by ipfs-inactive/interface-js-ipfs-core#308 License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: update interface-ipfs-core dependency License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: update ipfs-api dependency License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: fix the hack, open the repo not the datastore License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
* Fix for empty data in block. Found this very strange bug when creating DAGNode's with empty buffers for data. streamToValue returns an empty array when the data is empty, which down the line triggers an exception in ipfs-block because this sends an empty array instead of a buffer. * fix: get empty block for response without X-Stream-Output js-ipfs currently does not set the X-Stream-Output header on block.get responses so we also need a check for an empty array on our buffered res. License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io> * chore: update to latest interface-ipfs-core License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
Found this very strange bug when creating DAGNode's with empty buffers for data.
streamToValue returns an empty array when the data is empty, which down the line triggers an exception in ipfs-block because this sends an empty array instead of a buffer.