Skip to content

Conversation

@achingbrain
Copy link
Member

@achingbrain achingbrain commented Nov 27, 2025

The Accept-header driven translation between various IPLD formats is lossy, complicated, and often has us jumping through weird hoops to massage data into an acceptable format. Maybe we can do without it?

Simplifying the spec will make creating server implementations easier and the translation can still be done by clients if they require it.

The Accept-header driven translation between various IPLD formats
is lossy, complicated, and often has us jumping through weird hoops
to massage data into an acceptable format. Maybe we can do without
it?

Simplifying the spec will make creating server implementations
easier and the translation can still be done by clients if they
require it.

Refs: ipfs/gateway-conformance#200
@github-actions
Copy link

🚀 Build Preview on IPFS ready

@achingbrain achingbrain marked this pull request as ready for review November 27, 2025 13:51
@achingbrain achingbrain requested review from a team and lidel as code owners November 27, 2025 13:51
lidel added a commit to ipfs/gateway-conformance that referenced this pull request Dec 3, 2025
Update tests to reflect IPIP-0524 which removes codec conversions from
the gateway spec. Gateways now return 406 Not Acceptable when the
requested format doesn't match the block's codec.

- Replace TestDagPbConversion with TestCodecMismatchReturns406
- Remove codec conversion tests (dag-pb→dag-json, dag-cbor→dag-json)
- Fix TestPathing to request matching codec format
- Add body verification for DAG-CBOR traversal test
- Clarify that HTML rendering remains in spec (unlike conversions)

Implementations supporting optional codec conversions for backward
compatibility are free to skip the 406 tests.

Ref: ipfs/specs#524
lidel added a commit to ipfs/boxo that referenced this pull request Dec 3, 2025
Add AllowCodecConversion to gateway.Config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec. When true, conversions between codecs are performed for backward
compatibility.

Codec conversion tests moved here from gateway-conformance since
conversions are now an optional implementation feature, not a spec
requirement. Gateway-conformance now tests for 406 responses.

Ref: ipfs/specs#524
Ref: ipfs/gateway-conformance#254
lidel added a commit to ipfs/boxo that referenced this pull request Dec 3, 2025
Add AllowCodecConversion to gateway.Config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec. When true, conversions between codecs are performed for backward
compatibility.

Codec conversion tests moved here from gateway-conformance since
conversions are now an optional implementation feature, not a spec
requirement. Gateway-conformance now tests for 406 responses.

Ref: ipfs/specs#524
Ref: ipfs/gateway-conformance#254
lidel added a commit to ipfs/boxo that referenced this pull request Dec 3, 2025
Add AllowCodecConversion to gateway.Config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec. When true, conversions between codecs are performed for backward
compatibility.

Codec conversion tests moved here from gateway-conformance since
conversions are now an optional implementation feature, not a spec
requirement. Gateway-conformance now tests for 406 responses.

Ref: ipfs/specs#524
Ref: ipfs/gateway-conformance#254
lidel added a commit to ipfs/boxo that referenced this pull request Dec 3, 2025
Add AllowCodecConversion to gateway.Config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec. When true, conversions between codecs are performed for backward
compatibility.

Codec conversion tests moved here from gateway-conformance since
conversions are now an optional implementation feature, not a spec
requirement. Gateway-conformance now tests for 406 responses.

Ref: ipfs/specs#524
Ref: ipfs/gateway-conformance#254
lidel added a commit to ipfs/boxo that referenced this pull request Dec 3, 2025
Add AllowCodecConversion to gateway.Config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec. When true, conversions between codecs are performed for backward
compatibility.

Codec conversion tests moved here from gateway-conformance since
conversions are now an optional implementation feature, not a spec
requirement. Gateway-conformance now tests for 406 responses.

Ref: ipfs/specs#524
Ref: ipfs/gateway-conformance#254
lidel added a commit to ipfs/kubo that referenced this pull request Dec 3, 2025
Wire up boxo's AllowCodecConversion config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec.

Clients should fetch raw blocks (`?format=raw`) and convert client-side.

Ref: ipfs/specs#524
Ref: ipfs/boxo#1077
Ref: ipfs/gateway-conformance#254
lidel added a commit to ipfs/kubo that referenced this pull request Dec 3, 2025
Wire up boxo's AllowCodecConversion config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec.

Clients should fetch raw blocks (`?format=raw`) and convert client-side.

Ref: ipfs/specs#524
Ref: ipfs/boxo#1077
Ref: ipfs/gateway-conformance#254
lidel added a commit to ipfs/kubo that referenced this pull request Dec 3, 2025
Wire up boxo's AllowCodecConversion config to control codec conversion
behavior per IPIP-0524. When false (default), the gateway returns
406 Not Acceptable if the requested format doesn't match the block's
codec.

Clients should fetch raw blocks (`?format=raw`) and convert client-side.

Ref: ipfs/specs#524
Ref: ipfs/boxo#1077
Ref: ipfs/gateway-conformance#254
Copy link
Member

@lidel lidel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small clarification question inline, but other than that looks sensible, removes complexity related to a niche feature which can be implemented in userland thanks to ?format=raw.

Cleaned up conformance in:

GO implementation in Boxo/Kubo allows opt-in to previous behavior, just in case anyone depended on this niche feature from IPLD era:

Comment on lines +164 to +165
- [application/json](https://www.iana.org/assignments/media-types/application/json)Validates block data as JSON before returning it as-is. Invalid JSON produces 406 Not Acceptable.
- [application/cbor](https://www.iana.org/assignments/media-types/application/cbor)Validates block data as CBOR before returning it as-is. Invalid CBOR produces 406 Not Acceptable.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@achingbrain how strong you feel about doing actual JSON or CBOR parsing here, when plain version is requested?

The main purpose here, in my mind, is not data validation, but to maximize interop ensure correct Content-Type in response, as there are tools which will make request but wont parse response if its not application/json etc.

Could we simplify spec here noting that if requested CID codec is matching [dag-]json or [dag-]cbor, we dont parse payload, but return the same response as raw but with specific vanilla content type.

It makes implementation simpler (no need to deal with CBOR/JSON parsing edge cases), reduces cost of running gateway (no JSON/CBOR parsing), but we still have the interop benefit of returning vanilla JSON/CBOR when necessary by a third-party system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants