fix(lambda): preserve query string so function-level middleware runs - #1691
fix(lambda): preserve query string so function-level middleware runs#1691edenbuilds wants to merge 1 commit into
Conversation
Function-level middleware matches fnId from url.searchParams; dropping the query string on Lambda silently skipped those hooks while execution still worked.
🦋 Changeset detectedLatest commit: 5dabfe9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
LGTM
Correct and well-scoped fix. The v2 path uses url.search = rawQueryString which correctly handles the un-prefixed string per the URL spec. The v1 path properly filters out null values from queryStringParameters. The riskiest hunk (line 70, url.search = rawQueryString) is safe because the WHATWG URL setter auto-prepends ? when absent, matching API Gateway v2's format.
What this PR does
Extracts URL construction into a buildLambdaUrl helper that preserves the query string from API Gateway v1 (queryStringParameters) and v2 (rawQueryString) events, fixing function-level middleware resolution of fnId via url.searchParams.
Tag @mendral-app with feedback or questions. View session
…faults (#1698) ## Summary Function-level middleware was matched by reading `fnId` from `url.searchParams`, while execution resolves it via `queryStringWithDefaults` (adapter's `queryString()` first). On adapters whose `url()` drops the query string (Lambda, Redwood, DigitalOcean), middleware matching silently found nothing, so functions ran with client-level middleware only. This resolves `fnId` for middleware matching the same way execution does, which fixes all affected adapters. Adds an integration test that serves through the real Lambda adapter and fails without the fix. ## Checklist - [ ] ~~Added a docs PR that references this PR~~ N/A Bug fix, no API change - [x] Added unit/integration tests - [x] Added changesets if applicable ## Related - EXE-2144 - Fixes #1673 - Supersedes the adapter-level portion of #1691
Summary
url()rebuilt the request URL from the path only, dropping the query string.InngestCommHandlerattaches function-level middleware by readingfnIdfromurl.searchParams, so those hooks never ran on Lambda (client middleware still worked; execution still worked viaqueryString).rawQueryString(API Gateway v2) /queryStringParameters(v1) on the constructed URL.Fixes #1673
Test plan
buildLambdaUrlcovering v1 + v2 query preservationurl.searchParams.get("fnId")isnull; with the fix it returns the expected idvitest run src/lambda.test.ts)Made with Cursor