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

ipfs object get with protobuf encoding never errors in HTTP API #2468

Closed
RichardLitt opened this issue Mar 15, 2016 · 10 comments · Fixed by #5653
Closed

ipfs object get with protobuf encoding never errors in HTTP API #2468

RichardLitt opened this issue Mar 15, 2016 · 10 comments · Fixed by #5653
Labels
help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws)

Comments

@RichardLitt
Copy link
Member

ipfs object get --encoding=protobuf works using the normal CLI:

$ ipfs object get QmW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ --enc=protobuf
1
" ? :?^?E???p??\?|?.??t|d??U??cat.jpg?
$  ipfs object get kitten --enc=protobuf
Error: invalid ipfs ref path

However, when put through the HTTP API, it will not return an error if the key is invalid or missing.

13:07 ~/src/http-api-spec (feature/object) 🐕 curl -i -X POST "http://localhost:5001/api/v0/object/get?arg=&encoding=protobuf"
HTTP/1.1 200 OK
Server: go-ipfs/0.4.0-dev
Date: Tue, 15 Mar 2016 17:07:58 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8

13:07 ~/src/http-api-spec (feature/object) 🐕  curl -i -X POST "http://localhost:5001/api/v0/object/get?arg=kitten&encoding=protobuf"
HTTP/1.1 200 OK
Server: go-ipfs/0.4.0-dev
Date: Tue, 15 Mar 2016 17:08:01 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8

13:08 ~/src/http-api-spec (feature/object) 🐕  curl -i -X POST "http://localhost:5001/api/v0/object/get?arg=mW2WQi7j6c7UgJTarActp7tDNikE4B2qXtFCfLPdsgaTQ&encoding=protobuf"
HTTP/1.1 200 OK
Server: go-ipfs/0.4.0-dev
Date: Tue, 15 Mar 2016 17:08:15 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8

This should be solved before merging ipfs-inactive/http-api-spec#32.

@RichardLitt RichardLitt added the kind/bug A bug in existing code (including security flaws) label Mar 20, 2016
@RichardLitt
Copy link
Member Author

Blocking ipfs-inactive/http-api-spec#67.

@Stebalien
Copy link
Member

Would it be acceptable to return a JSON error?

@RichardLitt
Copy link
Member Author

Sure. But that needs to be returned.

Stebalien added a commit to Stebalien/go-ipfs that referenced this issue Mar 30, 2016
When `--encoding=protobuf` was set, `object get` used to always return a 200
response and would leave the body blank on error. Now, it returns a JSON error.

fixes ipfs#2468

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
Stebalien added a commit to Stebalien/go-ipfs that referenced this issue Mar 31, 2016
When `--encoding=protobuf` was set, `object get` used to always return a 200
response and would leave the body blank on error. Now, it returns a JSON error.

fixes ipfs#2468

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
Stebalien added a commit to Stebalien/go-ipfs that referenced this issue Mar 31, 2016
When `--encoding=protobuf` was set, `object get` used to always return a 200
response and would leave the body blank on error. Now, it returns a JSON error.

fixes ipfs#2468

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
@RichardLitt
Copy link
Member Author

It should at least return a status code of 500.

@Stebalien
Copy link
Member

We really shouldn't ever be returning 500 (500 means the application had some internal error it couldn't handle). Cases:

  • Bad Multihash: 400 (it's a malformed request).
  • IPFS object couldn't be found (but may exist somewhere): 504.
  • IPFS path is impossible (e.g., /ipfs/$hash/a/b where a/b doesn't resolve relative to the object named by $hash): 410 (gone).
  • IPNS path doesn't currently resolve (but we found the IPNS record and the associated IPFS object(s)): 404 (not found).

@RichardLitt
Copy link
Member Author

@Stebalien Fascinating!

@whyrusleeping What do you think about this? Might be a wider-reaching issue.

@whyrusleeping
Copy link
Member

@Stebalien how much of this has been addressed by your latest PR?

Stebalien added a commit to Stebalien/go-ipfs that referenced this issue May 30, 2016
When `--encoding=protobuf` was set, `object get` used to always return a 200
response and would leave the body blank on error. Now, it returns a JSON error.

fixes ipfs#2468

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
@Stebalien
Copy link
Member

My PR only returns a 500 error (with json content) when object get --encoding=protobuf fails. Nothing more.

@whyrusleeping whyrusleeping added the help wanted Seeking public contribution on this issue label Aug 23, 2016
@whyrusleeping whyrusleeping removed their assignment Aug 23, 2016
@Stebalien
Copy link
Member

So, this now does return a 500 error. It should probably return something else but that will require some changes to the API (we can revisit semantic errors later, right after we move away from the HTTP API to an RPC based API) . I'd call this specific issue fixed.

@Stebalien
Copy link
Member

Ok, so I think this is fixed. However, the error producing the 500 is actually a panic in the daemon so I'm going to wait for that issue to be fixed before declaring this fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Seeking public contribution on this issue kind/bug A bug in existing code (including security flaws)
Projects
None yet
3 participants