Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

"400 bad request" is returned for non-existing objects instead of 404 #30

Closed
roman-khimov opened this issue Apr 29, 2021 · 2 comments · Fixed by #80
Closed

"400 bad request" is returned for non-existing objects instead of 404 #30

roman-khimov opened this issue Apr 29, 2021 · 2 comments · Fixed by #80
Assignees
Labels
bug Something isn't working

Comments

@roman-khimov
Copy link
Member

$ LANG=C wget http://localhost:8082/get/Dxhf4PNprrJHWWTG5RGLdfLkJiSQ3AQqit1MSnEPRkDZ/Dinq6fbQR9Ry1NQvp4YzmTgDXCQ5SYQ9FR7koyTFjb2a
--2021-04-30 00:19:35--  http://localhost:8082/get/Dxhf4PNprrJHWWTG5RGLdfLkJiSQ3AQqit1MSnEPRkDZ/Dinq6fbQR9Ry1NQvp4YzmTgDXCQ5SYQ9FR7koyTFjb2a
Resolving localhost (localhost)... ::1, 127.0.0.1
Connecting to localhost (localhost)|::1|:8082... failed: Connection refused.
Connecting to localhost (localhost)|127.0.0.1|:8082... connected.
HTTP request sent, awaiting response... 400 Bad Request
2021-04-30 00:19:35 ERROR 400: Bad Request.

Gate log:

2021-04-30T00:19:35.457+0300    error   downloader/download.go:104      could not receive object        {"cid": "Dxhf4PNprrJHWWTG5RGLdfLkJiSQ3AQqit1MSnEPRkDZ", "oid": "Dinq6fbQR9Ry1NQvp4YzmTgDXCQ5SYQ9FR7koyTFjb2a", "elapsed": "63.078586ms", "error": "reading the response failed: rpc error: code = Unknown desc = object not found", "errorVerbose": "rpc error: code = Unknown desc = object not found\nreading the response failed\ngithub.com/nspcc-dev/neofs-api-go/pkg/client.(*clientImpl).GetObject\n\tgithub.com/nspcc-dev/[email protected]/pkg/client/object.go:542\ngithub.com/nspcc-dev/neofs-http-gate/neofs.(*neofsObjectClient).Get\n\tgithub.com/nspcc-dev/neofs-http-gate/neofs/client-plant.go:128\ngithub.com/nspcc-dev/neofs-http-gate/downloader.(*request).receiveFile\n\tgithub.com/nspcc-dev/neofs-http-gate/downloader/download.go:102\ngithub.com/nspcc-dev/neofs-http-gate/downloader.(*Downloader).DownloadByAddress\n\tgithub.com/nspcc-dev/neofs-http-gate/downloader/download.go:214\ngithub.com/fasthttp/router.(*Router).Handler\n\tgithub.com/fasthttp/[email protected]/router.go:414\ngithub.com/valyala/fasthttp.(*Server).serveConn\n\tgithub.com/valyala/[email protected]/server.go:2219\ngithub.com/valyala/fasthttp.(*workerPool).workerFunc\n\tgithub.com/valyala/[email protected]/workerpool.go:223\ngithub.com/valyala/fasthttp.(*workerPool).getCh.func1\n\tgithub.com/valyala/[email protected]/workerpool.go:195\nruntime.goexit\n\truntime/asm_amd64.s:1371"}

The problem is that even though desc has proper object not found string the code is Unknown and thus we return this generic error 400 instead of more appropriate 404. I'm not sure this happens and it doesn't seem to be critical, but maybe @alexvanin knows something about it (we're doing a GetObject call here (WithAddress/WithSession/WithBearer)).

@roman-khimov
Copy link
Member Author

Bad container ID is handled similarly:

2021-04-30T09:43:31.315+0300    error   downloader/download.go:104      could not receive object        {"cid": "Dxhf4PNprrJHWWTG5RGLdfLkJiSQ3AQqit1MSnEPRkDD", "oid": "Dinq6fbQR9Ry1NQvp4YzmTgDXCQ5SYQ9FR7koyTFjb2a", "elapsed": "3.750129ms", "error": "reading the response failed: rpc error: code = Unknown desc = can't fetch container info", "errorVerbose": "rpc error: code = Unknown desc = can't fetch container info\nreading the response failed\ngithub.com/nspcc-dev/neofs-api-go/pkg/client.(*clientImpl).GetObject\n\tgithub.com/nspcc-dev/[email protected]/pkg/client/object.go:542\ngithub.com/nspcc-dev/neofs-http-gate/neofs.(*neofsObjectClient).Get\n\tgithub.com/nspcc-dev/neofs-http-gate/neofs/client-plant.go:128\ngithub.com/nspcc-dev/neofs-http-gate/downloader.(*request).receiveFile\n\tgithub.com/nspcc-dev/neofs-http-gate/downloader/download.go:102\ngithub.com/nspcc-dev/neofs-http-gate/downloader.(*Downloader).DownloadByAddress\n\tgithub.com/nspcc-dev/neofs-http-gate/downloader/download.go:214\ngithub.com/fasthttp/router.(*Router).Handler\n\tgithub.com/fasthttp/[email protected]/router.go:414\ngithub.com/valyala/fasthttp.(*Server).serveConn\n\tgithub.com/valyala/[email protected]/server.go:2219\ngithub.com/valyala/fasthttp.(*workerPool).workerFunc\n\tgithub.com/valyala/[email protected]/workerpool.go:223\ngithub.com/valyala/fasthttp.(*workerPool).getCh.func1\n\tgithub.com/valyala/[email protected]/workerpool.go:195\nruntime.goexit\n\truntime/asm_amd64.s:1371"}

@alexvanin
Copy link
Contributor

NeoFS is doing poor job of error handling right now. While details (string messages) are somewhat useful, error codes are mostly ignored. This happened because error codes and error handling in general are tightly coupled with transport implementation. We want to break that coupling by defining error handling mechanism directly in NeoFS API in the future (nspcc-dev/neofs-api#150).

If it will be necessary, we can handle and return sensible gRPC error codes for some number of cases. Otherwise it is better to wait for transport independent NeoFS errors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants