ipfs / boxo

A set of reference libraries for building IPFS applications and implementations in Go.
https://github.com/ipfs/boxo#readme
Other
181 stars 83 forks source link

gateway: ipld.ErrNotFound should result in a 404 #593

Open MichaelMure opened 3 months ago

MichaelMure commented 3 months ago

It's a somewhat rare case, but it's possible for a gateway backend to return ipld.ErrNotFound:

In those situations, kubo v0.22.0 / boxo v0.11.0 would return a 404 in the gateway, but the implementation rework changed that to return a 500.

See also https://github.com/ipfs/boxo/pull/440/files#r1297472794

I think 404 is the correct answer, as this is not a timeout while looking for content on the p2p network, or some missing link in an IPLD node (which would mean an incorrect request). It's a definitive answer that the content does not exist.

Optionally, another status code could be returned in some more specific situations (see https://github.com/ipfs/boxo/issues/591), but 404 seem to be the correct default to me.

https://github.com/MichaelMure/boxo/commit/d088e1ea7664f04bd90e20ee3ec8a9ba4147a178 trivially change that returned status, with no other impact as far as I can tell.