Repository navigation
Fix Next.js locale matching and Pages Router request routing - #394
soleil-colza wants to merge 7 commits into
Conversation
|
Arkor — Preview deployments for arkorlab-upwind Use the checkbox below to choose whether this pull request gets preview deployments.
Checking this builds the latest commit and future pushes. Unchecking stops queued and future builds; a running build can finish and an existing preview stays available. |
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Locale pattern analysis and work budgeting packages/core/src/request/middleware-locale.ts, packages/core/src/request/pattern-budget.ts, packages/core/src/bundle/pattern-budget.ts |
Locale pattern parsing now caches supported forms. Locale-aware analysis reserves request-scoped pattern work. |
Payload suffix matching packages/core/src/paas/payload-matcher.ts |
Payload splitting supports JSON-only and RSC-capable suffixes. After budget refusal, locale-aware analysis can return false for a proven locale mismatch. |
Matcher tests and CI coverage .github/workflows/ci.yaml, packages/adapter/test/* |
Tests compare emitted Next.js matchers across configurations and payload grammars. CI runs the adapter and runtime tests against Next.js 16.2.0. |
Locale request capture and redirects
| Layer / File(s) | Summary |
|---|---|
Locale request protocol packages/core/src/paas/locale-request.ts, packages/core/src/paas/protocol.ts, packages/core/src/paas/middleware.ts, packages/core/src/paas/index.ts, packages/core/test/locale-request.test.ts |
The locale request shape captures language and cookie values, supports validated Base64URL encoding, and is exposed through a platform request header. |
Edge capture and forwarding packages/edge/src/handlers/locale-request.ts, packages/edge/src/handlers/{document-upstream,image-source,image-source-rewrite,middleware,passthrough}.ts, packages/edge/src/route.ts, packages/edge/src/strategies/{context,continuation-resume}.ts, packages/edge/test/{image-source-routing,locale-request}.test.ts |
The edge captures locale inputs for eligible roots and forwards them through middleware continuations. Tests cover overrides, rewrites, and paths that do not forward the carrier. |
Runtime locale negotiation and redirect packages/runtime/src/{handle,handoff,incoming,locale-language,locale-redirect,middleware-invoke,outputs,resolve-request,routing,serve,source-input}.ts, packages/runtime/test/locale-redirect.test.ts, packages/runtime/NOTICE |
The runtime uses original locale inputs, language preferences, cookies, and domain configuration to select root locale redirects before middleware or routing continues. |
Pages rewrite query propagation
| Layer / File(s) | Summary |
|---|---|
Effective query routing and request metadata packages/runtime/src/{handle,outputs,routing,serve,source-input}.ts |
Routing returns the effective Pages query separately from the public URL and adds it to handler request metadata. Source requests clear routing metadata. |
Query handoff and validation packages/runtime/src/{handoff,handle}.ts, packages/runtime/test/{handoff,pages-rewrite-query}.test.ts |
Handoffs carry validated effective queries. Tests check duplicate UTF-8 values and rewrite parameters through direct routing and split handoffs. |
Priority:
Estimated code review effort: 4 (Complex) | ~60 minutes
Change: Bug fix
Sequence Diagram(s)
sequenceDiagram
participant EdgeRoute
participant rootLocaleRequest
participant runMiddlewareIn
participant resumeRequest
participant initialRequestOf
participant preferredLocaleRedirect
EdgeRoute->>rootLocaleRequest: Capture locale inputs for an eligible root
EdgeRoute->>runMiddlewareIn: Pass locale request in edge context
runMiddlewareIn->>resumeRequest: Return continuation with locale request
resumeRequest->>initialRequestOf: Forward encoded locale request header
initialRequestOf->>preferredLocaleRedirect: Provide decoded original locale inputs
Possibly related PRs
- arkorlab/upwind#286: Updates the Next.js version used for matcher comparisons, which defines a matcher contract tested here.
- arkorlab/upwind#350: Adds pattern budgeting and locale-pattern decomposition used by this change’s bounded matcher analysis.
- arkorlab/upwind#383: Changes Pages handler URL construction, which is also extended here with separate effective query propagation.
Suggested reviewers: k-taro56
Merge Risk: 
Minimal · previous review e3392
-
No issue requiring a change before merge was established. The added CI lane selects the intended tests, and no material locale-routing failure was found.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 warning Passed checks: 4 passedFull details: Docstring Coverage
-
Explanation
Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 52 functions across 36 files. (2 skipped: 2 unsupported.)
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
-
Finishing Touches: 💡 1
-
📝 Generate docstrings: 💡
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
[Medium impact] The changes since the previous review appear safe to merge. SummaryThe PR fixes locale-aware middleware matching, preserves Pages rewrite queries, and adds original-root locale negotiation. Since the previous review:
Reviews (6) · Last reviewed commit: "fix(runtime): negotiate locales once bef..." · Reviewed by Greptile |
Fix three gaps in Next.js locale routing: ordinary locale-aware middleware paths could exceed the request pattern budget, Pages Router config rewrites could lose their added query under basePath, and root locale negotiation differed from Next.js.
Validation: focused matcher contracts pass on Next.js 16.4.3 (41 tests) and exact 16.2.0 (39 passed, two modern segment-payload cases skipped). Thirteen locale oracle/provenance cases pass on both versions. Fourteen query/handoff and 16 metadata cases pass, alongside focused local workerd regressions for real routing, edge handoff, spoofing, cache paths and image sources. The final real-router locale/slash suite passes 46 cases. Changed files pass scoped lint and formatting; full gates and exact-floor contracts run in CI. No benchmark or Cloudflare deployment.
Final commit 26f0f20 passes all required CI gates, including aggregate check, lint, tests, type/static checks and the local stack. Codex and Greptile reviewed that commit with no findings. CodeRabbit reported no actionable comments through e339274; its final incremental review is unavailable because the hourly review allowance is exhausted.