Skip to content

fix(gateway): a directory under a site's /_decdn/ serves its index.html - #2941

Merged
thiras merged 4 commits into
mainfrom
fix/2818-decdn-directory-index
Nov 25, 2026
Merged

thiras merged 4 commits into
mainfrom
fix/2818-decdn-directory-index

Conversation

@yigitdot

@yigitdot yigitdot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

On a site origin, a same-origin request for /_decdn/<h>/docs (a bundle with docs/index.html and no docs) redirected to docs/. The browser then asked for /_decdn/<h>/docs/, which the /_decdn/ branch parsed as-is, and decode_path refused the trailing empty segment with a 400. The redirect also dropped the ?ns= hint.

  • Under /_decdn/, a trailing / inside a bundle maps to …/index.html before parsing, for GET and HEAD, as a site's own paths already do.
  • A directory redirect keeps the request's query, under /_decdn/ (Location: docs/?ns=7) and on a site's own path (/docs?tab=2 → docs/?tab=2, GET and HEAD). Ask::Get carries the query to Gateway::entry.
  • A navigation or HEAD of a directory under /_decdn/ redirects to the directory on the bundle's site (https://<site>/docs/), not to its index.html.

No SDK contract test at the pinned commits requests a directory, so the pins do not move. The TypeScript and Python fake gateways still mirror the old redirect; decdn/sdk-typescript#29 and decdn/sdk-python#16 track them.

Closes #2818

Under /_decdn/, a trailing / inside a bundle maps to …/index.html before
parsing, for GET and HEAD, as a site's own paths already do. The
/_decdn/ directory redirect keeps the request's query, so its ns= hint
survives (Location: docs/?ns=7). Ask::Get carries the query to
Gateway::entry.

Closes #2818
Copilot AI balanced review requested due to automatic review settings November 23, 2026 01:25

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

@github-code-quality

github-code-quality Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Code coverage overview

Languages: Rust, Solidity

Rust / code-coverage/cargo-llvm-cov

main 528e730 fix/2818-decdn-direc... fc243e7 +/-
77% 77% 0%

Solidity / code-coverage/forge

main a1eeeb1 fix/2818-decdn-direc... fc243e7 +/-
93% 93% 0%

ℹ️ Calculations represent line coverage. Results may change as calculations are updated.


Updated November 25, 2026 00:11 UTC

A site's own-path directory redirect keeps the request's query, as the
/_decdn/ one does (/docs?tab=2 redirects to docs/?tab=2), on GET and
HEAD. A navigation or HEAD of a directory under /_decdn/ redirects to the
directory on the bundle's site (/docs/), not to its index.html.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The directory behavior change lacks the required SDK fake-gateway and contract-suite updates, and both SDK pins still reference versions with the old behavior.

1 open issue

Review effort: Balanced

Comment thread crates/cli/src/commands/gateway.rs Resolved
A Named enum (Directory, AsIs) replaces the bare directory bool that
head_blob and to_site take, so a call site reads as what it means.
yigitdot added a commit to decdn/sdk-python that referenced this pull request Nov 23, 2026
… its index.html

The fake gateway mirrors decdn/decdn#2941. On a site, a path naming a
directory with an index.html answers 302 to `<dir>/`, with the request's
query kept, for GET and HEAD. Under /_decdn/, a trailing `/` inside a
bundle serves the directory's index.html. HEAD of a bundle or an entry
under /_decdn/ redirects to its site at no pull, to the directory itself
when the request named one.

The contract fixture bundle gains docs/index.html, and a public contract
test covers these cases. It sends Sec-Fetch-Mode: cors and Sec-Fetch-Site:
same-origin, as a page's own request does.

Closes #16

Co-Authored-By: Claude Opus 5.5 <[email protected]>
yigitdot added a commit to decdn/sdk-python that referenced this pull request Nov 23, 2026
… its index.html

The fake gateway mirrors decdn/decdn#2941. On a site, a path naming a
directory with an index.html answers 302 to `<dir>/`, with the request's
query kept, for GET and HEAD. Under /_decdn/, a trailing `/` inside a
bundle serves the directory's index.html. HEAD of a bundle or an entry
under /_decdn/ redirects to its site at no pull, to the directory itself
when the request named one.

The contract fixture bundle gains docs/index.html, and a public contract
test covers these cases. It sends Sec-Fetch-Mode: cors and Sec-Fetch-Site:
same-origin, as a page's own request does.

Closes #16

Co-Authored-By: Claude Opus 5.5 <[email protected]>
yigitdot added a commit to decdn/sdk-python that referenced this pull request Nov 23, 2026
… its index.html (#17)

Closes #16. The fake gateway now mirrors decdn/decdn#2941.

## What changed

**Fake gateway (`tests/fake_gateway.py`)**
- **Site directory redirect:** on a site, a path that names a directory
with an `index.html` (and no entry of its own) answers `302 Location:
<dir>/`. The request's query is kept (`/docs?tab=2` → `docs/?tab=2`),
for GET and HEAD.
- **`/_decdn/` directory index:** a trailing `/` inside a bundle maps to
`index.html` before parsing. So `/_decdn/<h>/docs/` serves
`docs/index.html`, and `/_decdn/<h>/docs?ns=7` redirects to
`docs/?ns=7`. The bundle root `<h>/` is unchanged.
- **HEAD or navigation under `/_decdn/`:** a request with no
`Sec-Fetch-Mode`, or with `navigate`, counts as a navigation, as
`site::is_navigation` does.
- A HEAD or a navigation of a bundle or an entry redirects to that
bundle's site, without reading the manifest or charging the allowance.
- When the request named a directory, the redirect goes to the directory
itself (`/_decdn/<h>/docs/` → `http://<site>/docs/`).
- A blob is still served. Before this, a HEAD of a bundle or entry here
served the content, and so did a navigation.

**Contract**
- The fixture bundle gains `docs/index.html`, with no `docs` entry.
- A new public contract test, gated on `shipped_after("0.3.1")` since
v0.3.1 is decdn's latest release, checks:
- the site's own `/docs`, `/docs?tab=2`, `/docs/` and `/docs/?tab=2`,
plus `HEAD /docs?tab=2`;
  - `/_decdn/<h>/docs`, `…/docs?ns=7` and `…/docs/`;
  - `HEAD /_decdn/<h>/docs/` redirecting to the site's `/docs/`.
- It sends `sec-fetch-mode: cors` and `sec-fetch-site: same-origin`, as
sdk-typescript does, so the real gateway treats each request as the
page's own.
- It doesn't fetch `/_decdn/<h>/docs/?ns=7` from the real gateway:
there, `?ns=` routes the fetch through a namespace the e2e network may
not serve. The unit tests cover that case against the fake.

## Where this follows #2941 rather than the issue text
- A site's own directory redirect also keeps the query.
- HEAD of a `/_decdn/` directory goes to the directory on the site, not
to `docs/index.html`.

## Order of changes
This PR lands first. decdn/decdn#2941 then adds `docs/index.html` to the
bundle in `crates/e2e/src/sdk_contract.rs` and moves both SDK pins.
`harness-floor` is empty, so the floor doesn't change.

## Known gaps (not in this PR)
#20 tracks two older fake/real mismatches that nothing reads today:
- a blob navigation's `Content-Disposition`;
- the loopback site gate refusing a link from another site.

## Testing
- `uv run ruff check .`, `uv run ruff format --check .` and `uv run
mypy` are clean.
- `uv run pytest --ignore=tests/scripts`: 359 passed.
- The new contract test has run against the fake, not yet against the
real gateway. That needs #2941's harness change.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
… SDK pins

The contract bundle gains docs/index.html, with no docs entry, which the
SDK contract suites read for the directory cases. Both pins move to SDK
main commits whose fake gateway and contract suite carry the directory
behavior: sdk-typescript b88eb266 and sdk-python 55aceecd.
@github-actions

Copy link
Copy Markdown

Gas snapshot

No gas changes vs base.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues were identified for the gateway directory-handling fix.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@thiras
thiras enabled auto-merge (squash) November 25, 2026 00:11
@thiras
thiras merged commit e506796 into main Nov 25, 2026
37 checks passed
@thiras
thiras deleted the fix/2818-decdn-directory-index branch November 25, 2026 00:13
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.

gateway: a directory under a site's /_decdn/ redirects to a URI the gateway refuses

3 participants