ipfs / kubo

An IPFS implementation in Go
https://docs.ipfs.tech/how-to/command-line-quick-start/
Other
16.12k stars 3.01k forks source link

HTTP API return 404 error in different format than other endpoints #3468

Open haadcode opened 7 years ago

haadcode commented 7 years ago

Version information:

0.4.5-pre1.

Type:

Bug

Priority:

P3?

Description:

When the go-ipfs HTTP API is queried and an error occurs during the query, go-ipfs returns the error in format { Code: 500, Message: "Omg!" } (JSON). However, when the requested endpoint is not found and a 404 is returned, the error is not in JSON but a string.

This is annoying because we have to handle 404 separately from other errors in js-ipfs-api. It'd be great if all errors were returned in the same format.

Perhaps set the content-type header for 404 to 'application/json'.

whyrusleeping commented 7 years ago

This should be pretty easy to fix actually. Though is your example accurate? I don't think we ever return an object with code == 500 (or any http status codes for that matter)

whyrusleeping commented 7 years ago

I think for this one, we will want to wait for @keks refactor of the commands lib. It should make unification of everything a tad simpler

whyrusleeping commented 7 years ago

@lgierth did you latest PR solve this?

ghost commented 7 years ago

@lgierth did you latest PR solve this?

Nope