Skip to content

feat: tests for IPIP-548 Ipfs-Uri header - #301

Open
lidel wants to merge 3 commits into
mainfrom
ipip-548-ipfs-uri
Open

feat: tests for IPIP-548 Ipfs-Uri header#301
lidel wants to merge 3 commits into
mainfrom
ipip-548-ipfs-uri

Conversation

@lidel

@lidel lidel commented Aug 21, 2026

Copy link
Copy Markdown
Member

Need

X-Ipfs-Path cannot carry every UnixFS file name: bytes outside visible ASCII are invalid in HTTP field values1, so clients get garbled or silently mangled values, and nothing in the suite caught a gateway sending them. ipfs/specs#548 deprecates the header in favor of Ipfs-Uri, which the suite did not cover at all.

This PR

  • TestGatewayIpfsUri*: canonical ipfs:// / ipns:// serialization over a new dir-with-tricky-filenames.car fixture (spaces, %, #?, names in nine non-Latin scripts), authority normalization (CIDv0, base58 peer IDs), and one canonical value no matter how the request spells the path (raw sub-delims, lowercase hex) over the existing dir-with-percent-encoded-filename.car
  • TestGatewayIpfsUriLegacyXIpfsPathNotBroken fails gateways that return X-Ipfs-Path for paths that cannot survive a field value
  • existing X-Ipfs-Path expectations move to Ipfs-Uri; CORS tests expect it exposed

Depends on ipfs/specs#548. Verified against kubo built on the matching boxo branch.

Lmk if this is good as-is, or should be simplified to smaller set of fixtures.
In the past we kept it small due to maintenance burden, but refactoring is cheap these days, so we can afford full coverage, I think.

This needs to be released as a major version bump.

Tests

Kubo tests will fail in comments below until we bump kubo to boxo from ipfs/boxo#1209
Kubo PR that is green:

Footnotes

  1. RFC 9110, section 5.5: field values are limited to HTAB, SP, and visible ASCII; other bytes are invalid or replaced in transit.

@lidel
lidel requested a review from achingbrain August 21, 2026 02:17
@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Results against Kubo master:

Important

See the action summary for full results. This PR cannot be merged until there is a Kubo PR that uses tests from this branch and passes CI. Link related PRs (boxo, kubo) in the PR description.

Summary

Tests Failures Errors Skipped
1330 77 0 0

@github-actions

github-actions Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Results against Kubo latest:

Summary

Tests Failures Errors Skipped
1330 77 0 0

@lidel
lidel marked this pull request as draft August 21, 2026 02:43
lidel added a commit to ipfs/boxo that referenced this pull request Aug 21, 2026
Implement the Ipfs-Uri response header from ipfs/specs#548: a
canonical ipfs:// or ipns:// URI for the requested content path,
safe in an HTTP field value for any UnixFS file name.

- authority in canonical form: base32 CIDv1, base36 IPNS name
  keeping its multicodec, lowercase A-label DNSLink; header omitted
  when the root cannot be normalized
- every path segment percent-encoded over the RFC 3986 unreserved
  set with uppercase hex; "." and ".." emitted as %2E / %2E%2E
- sent on deserialized, redirect, and error responses up to 8192
  bytes, and exposed via default Access-Control-Expose-Headers
- X-Ipfs-Path no longer sent by default; restore via
  Config.DeprecatedXIpfsPath + Headers.WithDeprecatedXIpfsPath,
  still omitted for bytes invalid in a field value
- CI runs gateway-conformance from ipfs/gateway-conformance#301
  until a release with the IPIP-548 tests ships
@lidel
lidel force-pushed the ipip-548-ipfs-uri branch from 3e5aa8d to d51d978 Compare August 21, 2026 02:56
lidel added a commit to ipfs/boxo that referenced this pull request Aug 21, 2026
Implement the Ipfs-Uri response header from ipfs/specs#548: a
canonical ipfs:// or ipns:// URI for the requested content path,
safe in an HTTP field value for any UnixFS file name.

- authority in canonical form: base32 CIDv1, base36 IPNS name
  keeping its multicodec, lowercase A-label DNSLink; header omitted
  when the root cannot be normalized
- every path segment percent-encoded over the RFC 3986 unreserved
  set with uppercase hex; "." and ".." emitted as %2E / %2E%2E
- sent on deserialized, redirect, and error responses up to 8192
  bytes, and exposed via default Access-Control-Expose-Headers
- X-Ipfs-Path no longer sent by default; restore via
  Config.DeprecatedXIpfsPath + Headers.WithDeprecatedXIpfsPath,
  still omitted for bytes invalid in a field value
- CI runs gateway-conformance from ipfs/gateway-conformance#301
  until a release with the IPIP-548 tests ships
@lidel
lidel marked this pull request as ready for review August 21, 2026 03:37
@lidel
lidel force-pushed the ipip-548-ipfs-uri branch from d51d978 to 82ee9fa Compare August 22, 2026 12:33
lidel added a commit to ipfs/boxo that referenced this pull request Aug 22, 2026
Implement the Ipfs-Uri response header from ipfs/specs#548: a
canonical ipfs:// or ipns:// URI for the requested content path,
safe in an HTTP field value for any UnixFS file name.

- authority in canonical form: base32 CIDv1, base36 IPNS name
  keeping its multicodec, lowercase A-label DNSLink; header omitted
  when the root cannot be normalized
- every path segment percent-encoded over the RFC 3986 unreserved
  set with uppercase hex; "." and ".." emitted as %2E / %2E%2E
- sent on deserialized, redirect, and error responses up to 8192
  bytes, and exposed via default Access-Control-Expose-Headers
- X-Ipfs-Path no longer sent by default; restore via
  Config.DeprecatedXIpfsPath + Headers.WithDeprecatedXIpfsPath,
  still omitted for bytes invalid in a field value
- CI runs gateway-conformance from ipfs/gateway-conformance#301
  until a release with the IPIP-548 tests ships
Cover the Ipfs-Uri response header from ipfs/specs#548 and the
deprecation of X-Ipfs-Path, one request per failure class:

- canonical percent-encoded segments: delimiters, platform-encoder
  gaps (!'()*~), 4-byte UTF-8; full byte-level vectors live in the
  IPIP-0548 fixtures table
- request-spelling independence over
  dir-with-percent-encoded-filename.car: raw sub-delims and
  lowercase hex must yield the same canonical value
- decode-once normalization (%2F, %2E, dot segments), nested
  trailing slashes, query exclusion on alternate formats, redirects
- a hand-built fixture with a link literally named "a/b.txt" proves
  such an entry is not path-addressable: %2F always decodes to a
  separator, so the nested b.txt wins under every request spelling
- authority normalization: CIDv0 and legacy base58 peer IDs
- X-Ipfs-Path must be omitted for non-ASCII paths and unchanged
  when present for ASCII-safe ones; existing expectations move to
  Ipfs-Uri, raw block tests drop the header expectation, CORS
  expects Ipfs-Uri exposed
- DNSLink hosts get an ipns:// assertion in the dnslink suite
@lidel
lidel force-pushed the ipip-548-ipfs-uri branch from 82ee9fa to 149f396 Compare August 22, 2026 12:35
lidel added a commit to ipfs/boxo that referenced this pull request Aug 22, 2026
Implement the Ipfs-Uri response header from ipfs/specs#548: a
canonical ipfs:// or ipns:// URI for the requested content path,
safe in an HTTP field value for any UnixFS file name.

- authority in canonical form: base32 CIDv1, base36 IPNS name
  keeping its multicodec, lowercase A-label DNSLink; header omitted
  when the root cannot be normalized
- every path segment percent-encoded over the RFC 3986 unreserved
  set with uppercase hex; "." and ".." emitted as %2E / %2E%2E
- sent on deserialized, redirect, and error responses up to 8192
  bytes, and exposed via default Access-Control-Expose-Headers
- X-Ipfs-Path no longer sent by default; restore via
  Config.DeprecatedXIpfsPath + Headers.WithDeprecatedXIpfsPath,
  still omitted for bytes invalid in a field value
- CI runs gateway-conformance from ipfs/gateway-conformance#301
  until a release with the IPIP-548 tests ships
Per IPIP-548, only dotted DNSLink names can be an ipns:// authority: a
name with no dot can point at different content on each network. Add a
positive and a negative test over new dir_listing dnslink entries:
example.local yields ipns://example.local/, and examplenodot never
yields an Ipfs-Uri header, no matter how the gateway answers.

Refs ipfs/helia-verified-fetch#376 (comment)
lidel added a commit to ipfs/boxo that referenced this pull request Aug 23, 2026
Use the conformance tests from ipfs/gateway-conformance#301 at its
latest commit, which adds the dot-less DNSLink Ipfs-Uri tests.

```sh
ipfs version
# ipfs version 0.44.0-dev

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Better with a release version?

Suggested change
# ipfs version 0.44.0-dev
# ipfs version 0.43.0

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.

2 participants