Skip to content
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: ipfs get panic with empty API call #3768

Merged
merged 1 commit into from
Mar 9, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions core/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ may also specify the level of compression by specifying '-l=<1-9>'.
return err
},
Run: func(req cmds.Request, res cmds.Response) {
if len(req.Arguments()) == 0 {
res.SetError(errors.New("not enough arugments provided"), cmds.ErrClient)
return
}

cmplvl, err := getCompressOptions(req)
if err != nil {
res.SetError(err, cmds.ErrClient)
Expand Down
9 changes: 8 additions & 1 deletion test/sharness/t0090-get.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ test_get_fail() {
'

test_expect_success "ipfs get fails" '
test_expect_code 1 ipfs get QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr
test_expect_code 1 ipfs get QmaGidyrnX8FMbWJoxp8HVwZ1uRKwCyxBJzABnR1S2FVUr
'
}

Expand All @@ -154,6 +154,13 @@ test_get_fail
# should work online
test_launch_ipfs_daemon
test_get_cmd

test_expect_success "empty request to get doesn't panic and returns error" '
curl "http://$API_ADDR/api/v0/get" > curl_out || true &&
grep "not enough arugments provided" curl_out


'
test_kill_ipfs_daemon

test_done