-
-
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
fix: avoid out of bounds error when rendering short hashes #8318
Conversation
I think the problem is slightly different. It looks like |
8939fd4
to
39c76f8
Compare
Ah, I see. Yeah, that makes no sense. |
(caught higher up but should still be fixed)
39c76f8
to
4742934
Compare
I believe we figured that these were for "informational purposes", but really, we _should_ always be able to resolve names to CIDs. If we can't, there's probably something wrong with the directory.
4742934
to
66a76d2
Compare
I fixed it both ways. |
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.
Thanks for the quick fix, it seems correct to me. I'd like to understand if there was some logic for why we didn't do this check before to make sure we don't introduce a different error (left as a comment)
resolved, err := i.api.ResolvePath(r.Context(), ipath.Join(resolvedPath, dirit.Name())) | ||
if err != nil { | ||
internalWebError(w, err) | ||
return | ||
} | ||
hash := resolved.Cid().String() |
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.
@lidel what was the idea behind "Path may not be resolved. Continue anyways.", it seems like we should just fail here as this PR does?
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.
Also, how do we even reach the point where we error here? It seems like the UnixFS directory is telling us "here are the objects I have" and then we look for them and it errors.
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.
Also, how do we even reach the point where we error here? It seems like the UnixFS directory is telling us "here are the objects I have" and then we look for them and it errors.
Invalid sharded directory. Or a subshard of a sharded directory that we can list but can't traverse.
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.
Not knowing the codebase before, SGTM. The previous code was definitely open to panics.
I guess you could just do the shortHash change to avoid panics. I don't have enough context to tell if err != nil
should continue or stop.
Ok, I'm going to merge this for now. We can change it later if there is a better fix. |
fix: avoid out of bounds error when rendering short hashes This commit was moved from ipfs/kubo@7c76118
The panic is caught higher up the stack so it can't crash the node, but it's still "not good".