-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Error: multihash too short. must be > 3 bytes. #2867
Comments
From looking at the package itself, the only code I could find with this error message was as follows:
From the looks of it, it should be working, so I'm not sure why this is erroring out like it is |
@obo20 TLDR; the error message is deceptive but it's failing because
...and falls through to:
Back in Finally, the error we got from |
I guess this should be fixed with a more descriptive error message (that handles the case of invalid CIDs)? |
I would like to use something like For the time being I think in this case the best solution would be to fix That way we'll get an error message that makes much more sense in the context of the input. |
@alanshaw I'm looking into this and was wondering what you prefer:
This means, we basically wanna check for Buffer, isCID, cidString and ipfsPath beforehand. However, with how it is now, that would mean we'd only conditionally clean the hash e.g.:
with
In other words, if Is ^ that error the one we wanna propagate here? Another option would obviously to make it error right at the point we know input isn't valid. Something like:
In fact, we can get rid off the try catch block all together then:
However, at this point we don't know exactly why
|
…is valid Fixes #799 License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
Here's a proposal. Happy to change it to your needs: ipfs-inactive/js-ipfs-http-client#804 |
…is valid Fixes #799 License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
@alanshaw you're prolly super busy with things, but maybe you'll find 2 minutes to give my last comment here a quick thought? :) I'll then update the PR accordingly and serve it on a golden plate (and stop annoying you with it). |
Apologies I completely forgot about this one - I have commented on your PR now, let me know what you think! |
No worries. We've all got stuff to do :) I've read your comment and am working on updating the PR. Trying to come up with a test as well, so we can verify the expected behavior. Stay tuned. |
To verify changes discussed in https://github.com/ipfs/js-ipfs-api/issues/799#issuecomment-402086401, this commit adds a test that checks `files.cat()` throws a meaningful error when a key or ipfs path with unsupported encoding is given. License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
… `cat()` A test to verify this is available at ipfs-inactive/interface-js-ipfs-core#330 and needs to be merged first. Fixes #799 License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
… `cat()` A test to verify this is available at ipfs-inactive/interface-js-ipfs-core#330 and needs to be merged first. Fixes #799 License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
To verify changes discussed in https://github.com/ipfs/js-ipfs-api/issues/799#issuecomment-402086401, this commit adds a test that checks `files.cat()` throws a meaningful error when a key or ipfs path with unsupported encoding is given. License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
A test to verify this is available at ipfs-inactive/interface-js-ipfs-core#330 and needs to be merged first. Fixes #799 License: MIT Signed-off-by: Pascal Precht pascal.precht@gmail.com
Calling await all(ipfs.cat('/ipfs/QmUzdHisA7ouM8DM5rVAKursVK7t7tKeqDYGvmaCdJw5jEeesdlfjsldkfjsldkfjsdlkfjskldfj')) now fails with
so the error message is at least less cryptic than it used to be. If a more descriptive error message is desired, a PR should be opened against multiformats/js-cid as that's where the string is turned into a CID. |
If you submit a request to get a file using ipfs.files.cat, and you have a hash that is greater than 3 bytes, you still get the error message: "Error: multihash too short. must be > 3 bytes."
For example:
ipfs.files.cat(/ipfs/QmUzdHisA7ouM8DM5rVAKursVK7t7tKeqDYGvmaCdJw5jEeesdlfjsldkfjsldkfjsdlkfjskldfj
will return that error messageThe text was updated successfully, but these errors were encountered: