-
Notifications
You must be signed in to change notification settings - Fork 1.2k
files.cat(cid.buffer) throws error: multihash length inconsistent #1247
Comments
Just to be clear, |
I cannot |
Same issue as #1229 |
Hi @diasdavid, I started looking into this issue (along with #1229, which you stated was the same issue), and I'm a little stumped on why they are actually the same issue? According to this bug report, it looks like he is in fact correctly supplying a CID of type Buffer (cid.buffer), and the issue seems to be due to inconsistent hash length. My best guess is that there is some inconsistency or misuse in how he is generating his multihash and CID (steps 1-4 in the description). However, on #1229, the issue is slightly different in that he is actually supplying a formal CID object, which the normalizePath function does not handle. The resolution to that problem seems to just require an enhancement of the normalizePath method so that it can convert the CID into a b58 string. I'm looking to tackle one of these issues as my first contribution to the project, so I just want to make sure I'm looking at these issues correctly. Thoughts? Thanks! |
@brockmiller - that's correct about #1229 - the issue was that we were previously supplying a cid object to the function and it worked, and that stopped working. I think I've caught all the instances in my code, but I'm guessing other people's (previously working) code might also break. |
I analyzed this issue, but I could not reach a successful case. At first, the mentioned error: This occurs because of being used Using the following code: const content = 'Multiaddrs are cool.'
const buffer = api.Buffer.from(content)
ipfs.files.add(buffer, {}, (err, filesAdded) => {
const path = filesAdded[0].path
const cidCorrect = new node.types.CID(path)
console.log('cid', cidCorrect, cidCorrect.buffer);
}) If we analyze the CID obtained using the received path, besides version 1 being used, it is also being used Despite all this, I still trying to understand one problem, which happens in this case. const buffer = api.Buffer.from(content)
const mh = multihashing(buffer, 'sha2-256')
const cid = new node.types.CID(0, 'dag-pb', mh) The obtained CID is different than the obtained previously on |
Closing this as I believe it has been resolved. I can see that |
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:
Steps to reproduce the error:
Code snippets:
The text was updated successfully, but these errors were encountered: