Skip to content

fix(lambda): preserve query string so function-level middleware runs - #1691

Open
edenbuilds wants to merge 1 commit into
inngest:mainfrom
edenbuilds:fix/lambda-url-preserve-query
Open

fix(lambda): preserve query string so function-level middleware runs#1691
edenbuilds wants to merge 1 commit into
inngest:mainfrom
edenbuilds:fix/lambda-url-preserve-query

Conversation

@edenbuilds

Copy link
Copy Markdown

Summary

  • The AWS Lambda adapter's url() rebuilt the request URL from the path only, dropping the query string.
  • InngestCommHandler attaches function-level middleware by reading fnId from url.searchParams, so those hooks never ran on Lambda (client middleware still worked; execution still worked via queryString).
  • Preserve rawQueryString (API Gateway v2) / queryStringParameters (v1) on the constructed URL.

Fixes #1673

Test plan

  • Unit tests for buildLambdaUrl covering v1 + v2 query preservation
  • A/B: without the query-preservation block, url.searchParams.get("fnId") is null; with the fix it returns the expected id
  • Existing Lambda framework suite still passes (vitest run src/lambda.test.ts)

Made with Cursor

Function-level middleware matches fnId from url.searchParams; dropping the
query string on Lambda silently skipped those hooks while execution still worked.
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 5dabfe9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
inngest Patch

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

@mendral-app mendral-app 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.

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

Linell added a commit that referenced this pull request Aug 11, 2026
…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
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.

[BUG] Function-level middleware silently never runs on AWS Lambda — lambda adapter's url() drops the query string

1 participant