-
-
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
Daemon panics if no path is given #1265
Conversation
If no path after `/ipfs/` or `/ipns/` is given, then the daemon will panic with a slice bounds out of range error. This checks to see if we have anything after `ipfs` or `ipns`.
good catch! |
It was actually already there, just removed 13 days ago. 3ead244#diff-f666ab4b28c2e912b2339140db6061eeL50 Might put back in that same logic? It looks like a pretty complex commit and parts of it might of been removed for a particular reason. The length check needs to be there someplace though I believe still. |
On Wed, May 20, 2015 at 07:12:43PM -0700, Travis Person wrote:
Oops, sorry about that. And maybe a test to make sure I don't break |
@wking is adding back these lines alright, or should it be modified? if len(seg) < 2 || seg[1] == "" { // just "/ipns/"
return nil, fmt.Errorf("invalid path: %s", string(r.p))
} |
On Wed, May 20, 2015 at 07:55:10PM -0700, Travis Person wrote:
Well, // just "//" without further segments because the problem isn't restricted to /ipns/ (e.g. it could be |
Added the original logic to check for a invalid path and a simple test.
this LGTM. will merge after tests |
I agree, I enjoy named errors. We loose the formatting with named errors though. I'm not sure if it's all that important in this case though and am 100% okay with creating a new error instead. |
On Wed, May 20, 2015 at 09:18:30PM -0700, Travis Person wrote:
Is there a way around that? I'm not fluent in Go yet, but the idea |
At the very least we could do this: if !strings.HasPrefix(err.Error(), "invalid path:") { Which is probably a good idea, as the test I wrote actually fails on @jbenet hold off on merging this. |
Cleaned the tests, and actually test for the error.
(aside: error handling is clunky in general. feels unfinished.) |
ack |
As long as there are no further comments I think this is good to go. |
@travisperson i fixed the namesys issue you were running into. |
Daemon panics if no path is given
thanks @travisperson |
@travisperson looks like this PR made so i reverted :( previous merge head was 78defff Also noted commits are behind master. maybe rebase, PR again and see if it does indeed fail? (i don't want to keep introducing intermittent testing failures) |
the tests passed fine when it merged, and this isnt a thing that can be intermittent. |
If no path after
/ipfs/
or/ipns/
is given, then the daemon willpanic with a slice bounds out of range error. This checks to see if we
have anything after
ipfs
oripns
.