This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
files.cat(cid.buffer) throws error: multihash length inconsistent #1247
Closed
Description
- Version: 0.28.0
- Platform: Linux 4.13.0-36-generic update roadmap #40-Ubuntu SMP Fri Feb 16 20:07:48 UTC 2018 x86_64 x86_64 x86_64 GNU/Linu
- Subsystem: Node.js v6.11.5
Type: Bug
Severity: Medium
Description:
Not sure if I'm using the API correctly, but this is what I do:
(1) Create a buffer from a string content.
(2) Add a file using the buffer to an IPFS node.
(3) Create a CID with the buffer content (with version==1).
(4) Fetch the content using the API, files.cat(cid.buffer)
.
It throws the following exception:
Error: multihash length inconsistent: 0x122017babbbb5ec8d6ec709a5fd1b559d0126cf36486145f84f9c39260ae0d87ab7e
at Object.decode (/home/harry/js-ipfs/node_modules/multihashes/src/index.js:99:11)
at Object.validate (/home/harry/js-ipfs/node_modules/multihashes/src/index.js:210:11)
at Function.validateCID (/home/harry/js-ipfs/node_modules/cids/src/index.js:254:8)
at new CID (/home/harry/js-ipfs/node_modules/cids/src/index.js:104:9)
at pathBaseAndRest (/home/harry/js-ipfs/node_modules/ipfs-unixfs-engine/src/exporter/index.js:30:15)
at module.exports.err (/home/harry/js-ipfs/node_modules/ipfs-unixfs-engine/src/exporter/index.js:47:13)
at _catPullStream (/home/harry/js-ipfs/src/core/components/files.js:142:7)
at Function.cat.promisify (/home/harry/js-ipfs/src/core/components/files.js:234:9)
at Object.cat (/home/harry/js-ipfs/node_modules/promisify-es6/index.js:32:27)
at Timeout.setTimeout (/home/harry/js-ipfs/test/core/files-cat.spec.js:82:18)
at ontimeout (timers.js:386:11)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
Steps to reproduce the error:
Code snippets:
let buffer = Buffer.from(content);
let mh = multihashing(buffer, 'sha2-256')
let cid = new CID(1, 'dag-cbor', mh)
ipfs.files.add(buffer, {}, (err, filesAdded) => {
path = filesAdded[0].path;
console.log("Created: path = " + path)
})
// ...
ipfs.files.cat(cid.buffer, (err, data) => {
console.log(err)
console.log(data)
})