Skip to content

fix: collapse 742 trailing-slash redirect pairs to reclaim Vercel route headroom - #532

Merged
hongyi-chen merged 2 commits into
mainfrom
rrenk/collapse-redirect-pairs
Aug 14, 2026
Merged

fix: collapse 742 trailing-slash redirect pairs to reclaim Vercel route headroom#532
hongyi-chen merged 2 commits into
mainfrom
rrenk/collapse-redirect-pairs

Conversation

@rachaelrenk

Copy link
Copy Markdown
Contributor

Summary

vercel.json held 744 pairs of redirects that were byte-identical apart from the trailing slash, with the same destination and status code. Each pair burns two of the 2048 routes Vercel allows per deployment.

That ceiling has been a recurring problem: 27380fdf collapsed the /cli redirects to get under it, and #503 failed to deploy for the same reason and needed its own fix. main has been sitting close enough to the cap that ordinary PRs adding a redirect could not deploy.

Collapsing each pair into a single (/?) rule takes the file from 2034 to 1292 config routes.

redirects:     2029 -> 1287
config routes: 2034 -> 1292   (cap 2048)

Why both forms need a rule today

Vercel matches redirect sources literally — there is no trailing-slash normalization. Verified against production:

Rule that exists Request Result
with-slash only (/agent-platform/capabilities/web-search/) no-slash 404
no-slash only (/agents/using-agents/model-choice) with-slash 404

So the duplication is not redundant today. It is the only way to cover both forms — until one rule can do it.

The pattern

/path(/?) matches both /path and /path/. This uses the same unnamed-regex-group support the repo already relies on for /university/(.*).

Verified on a preview deployment, at small scale first and then on this branch:

/features/global-hotkey        308 -> /terminal/windows/global-hotkey/
/features/global-hotkey/       308 -> /terminal/windows/global-hotkey/
/features/global-hotkeyextra   404      (does not over-match adjacent paths)
/features/global-hotkey/deeper 404      (does not swallow descendants)
/prefix/features/global-hotkey 404      (anchored at the start)

Safety

Two guards in the transform:

  • Only plain-literal pairs with identical destination and status code are touched. Any source already containing a pattern is left alone.
  • Order is preserved. Vercel evaluates redirects in array order, so hoisting the with-slash form up to the position of the no-slash form could jump it ahead of a wildcard that currently wins. Any pair with a rule between its two entries that could match either form is skipped. That caught 2 pairs/errors and /university, which sit around /errors/:code and /university/(.*) — and they are left uncollapsed.

Validation

  • Equivalence proven, not assumed. All 2019 literal sources in the original file were resolved against both the old and new rule lists; every one lands on the same destination. The transform aborts if any mismatch is found.
  • 20 collapsed rules sampled and tested live, both URL forms each, comparing the preview against production: 40/40 identical status codes and Location headers.
  • Anchoring verified on the preview, as shown above.
  • npm run build — clean.
  • Internal link check — 0 broken across 3,490 links.
  • 0 duplicate sources; self-redirect count unchanged from main (2 benign no-slash normalizers).
  • The preview deploying at all is itself confirmation we are well under the route cap.

Follow-up, not included here

There are 53 retired paths whose no-slash form 404s today because only a with-slash rule was ever added. This PR does not change that behavior either way — collapsing only touches paths that already had both forms. Worth a separate pass now that there is headroom to add rules again.

Unverified claims

None. This changes only redirect routing config; no page content, slugs, or navigation are touched. Every behavioral claim above was checked against a live deployment rather than inferred from the config.

Co-Authored-By: Warp Agent agent@warp.dev

vercel.json held 744 pairs of redirects that were byte-identical apart
from the trailing slash, with the same destination and status code. Each
pair costs two of the 2048 routes Vercel allows per deployment, and main
had been sitting close enough to that ceiling that ordinary PRs were
failing to deploy (see 27380fd and the fix on #503).

Collapse each pair into one rule using the ':path(.*)'-adjacent '(/?)'
suffix, which matches both the bare path and the trailing-slash form.

  redirects:     2029 -> 1287
  config routes: 2034 -> 1292  (cap 2048)

Behavior is unchanged. Vercel matches redirect sources literally: a
with-slash-only rule 404s the no-slash form and vice versa, verified
against production on /agent-platform/capabilities/web-search and
/agents/using-agents/model-choice. The '(/?)' form was verified on a
preview deployment to match both forms while staying anchored, so
'/xextra', '/x/deeper', and '/prefix/x' all still miss.

Two safety guards:

- Only plain-literal pairs with identical destination- Only plain-literal pairs with identical destination- Only plain-litar- Only plain-literal pairs with identical destination- Only plainsting the with-slash
  form up to the position of the no-slash form could jump it ahead of a
  wildcard that currently wins. Any pair with a rule betw  wildcard that currently wins. Any pair with aorm is s  wildcard that currently wins. Any pair with a rule betw  wildcard tund /errors/:code and
  /university/(.*) and are left as-is.

Equivalence is proven rather than assumedEquivalence is proven rather thhe original file resolve to the same destination before and after.

Co-Authored-By: Warp Agent <agent@warp.dev>
@cla-bot cla-bot Bot added the cla-signed label Aug 14, 2026
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview Aug 14, 2026 6:12pm

Request Review

@oz-for-oss

oz-for-oss Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

@rachaelrenk

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overview

This PR collapses duplicate trailing-slash redirect pairs in vercel.json into single (/?) sources to reduce Vercel route usage without changing page content or navigation. I validated the attached diff by reconstructing the resulting config, parsing the JSON, checking redirect/source counts and uniqueness, and simulating the changed literal redirect paths for old-vs-new status/destination equivalence.

Concerns

  • No blocking concerns found.
  • No approved or repository spec context was available for implementation drift review.
  • No added or changed comments/tests were present in the diff.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@hongyi-chen
hongyi-chen merged commit 552835c into main Aug 14, 2026
8 checks passed
@hongyi-chen
hongyi-chen deleted the rrenk/collapse-redirect-pairs branch August 14, 2026 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants