|
| 1 | +--- |
| 2 | +title: "IPIP-0524: Remove IPLD Data Model translations from Gateways" |
| 3 | +date: 2025-11-27 |
| 4 | +ipip: proposal |
| 5 | +editors: |
| 6 | + - name: Alex Potsides |
| 7 | + github: achingbrain |
| 8 | + url: https://achingbrain.net |
| 9 | + affiliation: |
| 10 | + name: Shipyard |
| 11 | + url: https://ipshipyard.com |
| 12 | +relatedIssues: |
| 13 | + - https://github.com/ipfs/gateway-conformance/issues/200 |
| 14 | +order: 524 |
| 15 | +tags: ['ipips'] |
| 16 | +--- |
| 17 | + |
| 18 | +## Summary |
| 19 | + |
| 20 | +Make IPFS HTTP Gateway responses easier to reason about by not requiring IPLD |
| 21 | +Data Model translations |
| 22 | + |
| 23 | +## Motivation |
| 24 | + |
| 25 | +When sending an [Accept](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Accept) |
| 26 | +header or [format](https://specs.ipfs.tech/http-gateways/path-gateway/#format-request-query-parameter) |
| 27 | +query parameter to specify the response format of a request, the IPFS HTTP |
| 28 | +Gateway specs [allow translation](https://specs.ipfs.tech/http-gateways/path-gateway/#accept-request-header) |
| 29 | +of the requested content into the [IPLD Data Model](https://ipld.io/docs/data-model/). |
| 30 | + |
| 31 | +This adds significant complexity to HTTP Gateway implementations, since they |
| 32 | +need to be able to translate between arbitrary data types and handle all the |
| 33 | +various failure states. |
| 34 | + |
| 35 | +The conversions are also lossy due to differences in supported data types across |
| 36 | +different formats so lack general-purpose utility and are ultimately something |
| 37 | +that could be done on an interested client if required. |
| 38 | + |
| 39 | +## Detailed design |
| 40 | + |
| 41 | +An IPFS HTTP Gateway should make an attempt to verify that requested data can be |
| 42 | +represented in the desired response format (e.g. it should attempt to parse the |
| 43 | +block as JSON string or CBOR data when the relevant formats are requested, |
| 44 | +though in the case of CBOR it does not need to support all [tags](https://www.iana.org/assignments/cbor-tags/cbor-tags.xhtml) |
| 45 | +encountered in the block). |
| 46 | + |
| 47 | +If the block was loaded successfully but cannot be represented in the requested |
| 48 | +format, the server should return a [406](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/406). |
| 49 | + |
| 50 | +This would be the outcome if, for example a DAG-JSON block was requested with |
| 51 | +the `application/cbor` format. |
| 52 | + |
| 53 | +Where a human-readable rendering of the data is desired, the `text/html` format |
| 54 | +can be requested. This would allow browsing DAG-PB data, for example. |
| 55 | + |
| 56 | +A [400](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/400) |
| 57 | +may be returned if the request was invalid (for example an unsupported format |
| 58 | +was requested). |
| 59 | + |
| 60 | +A [500](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/500) |
| 61 | +may be returned in other circumstances. |
| 62 | + |
| 63 | +## Design rationale |
| 64 | + |
| 65 | +Simplifying the HTTP Gateway spec to remove these format translations and the |
| 66 | +additional logic required makes it more straightforward to create new |
| 67 | +implementations, and makes the returned data more transparent and so easier to |
| 68 | +understand since the data is not modified to fit the output format. |
| 69 | + |
| 70 | +Clients that wish to translate between different data formats may request raw |
| 71 | +blocks and do the translation themselves. |
| 72 | + |
| 73 | +### User benefit |
| 74 | + |
| 75 | +HTTP Gateways will be simpler to use having fewer options and they will be |
| 76 | +encouraged to adapt their clients for their individual use-cases where more |
| 77 | +advanced functionality is required. |
| 78 | + |
| 79 | +### Compatibility |
| 80 | + |
| 81 | +This is a breaking change. Data will no longer be translated between different |
| 82 | +formats by the server and that logic will shift to interested clients. |
| 83 | + |
| 84 | +## Test fixtures |
| 85 | + |
| 86 | +Implementers can run the [gateway-conformance](https://github.com/ipfs/gateway-conformance/) |
| 87 | +test suite. |
| 88 | + |
| 89 | +### Copyright |
| 90 | + |
| 91 | +Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/). |
0 commit comments