mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 19:24:14 +08:00
fix: ipfs get panic with empty API call
License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
@ -51,6 +51,11 @@ may also specify the level of compression by specifying '-l=<1-9>'.
|
|||||||
return err
|
return err
|
||||||
},
|
},
|
||||||
Run: func(req cmds.Request, res cmds.Response) {
|
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)
|
cmplvl, err := getCompressOptions(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrClient)
|
res.SetError(err, cmds.ErrClient)
|
||||||
|
@ -154,6 +154,13 @@ test_get_fail
|
|||||||
# should work online
|
# should work online
|
||||||
test_launch_ipfs_daemon
|
test_launch_ipfs_daemon
|
||||||
test_get_cmd
|
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_kill_ipfs_daemon
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
Reference in New Issue
Block a user