FORGE-290: keep encoded & in route handler query strings #1043
No reviewers
Labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
gmackie/ForgeGraph!1043
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "FORGE-290-query-decode"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes FORGE-290: https://tasks.gmac.io/gmacko/issue/FORGE-290
Cause
@opennextjs/aws4.1.0 (used by@opennextjs/cloudflare1.20.2) set a route handler'sreq.urlto the path plusconvertToQueryString(internalEvent.query). That query object is already decoded, andconvertToQueryStringjoined it without re-encoding, so a value's%26became a parameter separator (dist/core/requestHandler.js,setInitialURLoverride). Pages readinvokeQuery, so they were unaffected. The middleware was not involved: it passes the request through unchanged.Effect:
/api/auth/login?redirect=<authorize URL>stored only/api/mcp/oauth/authorize?response_type=code, so a signed-out sign-in from an MCP client (T3 Code) ended onInvalid client_id.Fix
This backports the upstream fix from
@opennextjs/aws4.1.9 as a pnpm patch (patches/@opennextjs__aws@4.1.0.patch):req.url = initialURL.pathname + initialURL.searchkeeps the raw query string.convertToQueryStringencodes throughURLSearchParams, which also covers rewrites and i18n.Upgrading instead isn't practical within this bug's scope:
@opennextjs/cloudflare1.20.10+ (which uses aws 4.1.9+) requiresnext >= 16.3.8, and we're on 16.3.0. Drop the patch when OpenNext is upgraded.Tests
apps/web/src/__tests__/opennext-query.test.tsreads the installed OpenNext files and fails if the patch stops applying. It passes with the patch and fails without it, checked locally.scripts/preview-smoke.mjssends both production repros to the PR preview's built Worker: the login redirect cookie keeps%26y%3D2, and the authorize return path keepsstate=a%26b.🤖 Generated with Claude Code
Worker Preview: https://pr-1043.previews.forgegraf.com (updates on every push; behind Cloudflare Access; shared previews database, the banner shows which PR owns it)