Skip to content

Return client errors for unrecognized Server Actions - #98123

Merged
gnoff merged 7 commits into
canaryfrom
jstory/server-action-status-codes
Sep 3, 2026
Merged

Return client errors for unrecognized Server Actions#98123
gnoff merged 7 commits into
canaryfrom
jstory/server-action-status-codes

Conversation

@gnoff

@gnoff gnoff commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • return 400 Bad Request when a Server Action reference ID does not match the expected format
  • return 409 Conflict when a well-formed action ID is unavailable in the current deployment, including deployment skew
  • apply the same classification to IDs from the Next-Action header and multipart MPA forms, including direct and bound actions in Node and Edge runtimes
  • return generic text bodies matching the client error category, without exposing action-ID details
  • derive marked forwarded-action responses from the original action ID so an unexpected or mixed-version worker response cannot change the client error semantics

Fetch actions previously had dedicated 404 handling, while equivalent MPA form submissions fell through to the generic error path and returned 500. This removes that transport-dependent behavior and distinguishes malformed or scanning traffic from legitimate stale clients without treating either case as a missing page or an internal server failure.

Verification

  • pnpm test-dev-turbo test/e2e/app-dir/actions-unrecognized/actions-unrecognized.test.ts
  • pnpm test-dev-turbo test/e2e/app-dir/actions/app-action.test.ts -t 'forward.*action'
  • pnpm test-start-turbo test/e2e/app-dir/actions-unrecognized/actions-unrecognized.test.ts
  • pnpm test-dev-webpack test/e2e/app-dir/actions-unrecognized/actions-unrecognized.test.ts
  • pnpm test-dev-turbo test/e2e/app-dir/no-server-actions/no-server-actions.test.ts

Return 400 for malformed Server Action reference IDs and 409 for well-formed references that are unavailable in the current deployment.

Preserve the worker response status when forwarding action requests, and cover apps both with and without Server Actions.

<!-- NEXT_JS_LLM -->
@github-actions

github-actions Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Tests Passed

Commit: 59b08ae

Classify action IDs embedded in multipart form submissions before React decodes them. Return 400 for malformed IDs and 409 for unavailable well-formed IDs instead of rethrowing them as 500 errors.

Add Node and Edge coverage for direct and bound MPA action encodings.

<!-- NEXT_JS_LLM -->
Keep multipart action validation boolean instead of returning an error/status tuple. Inline the HTTP mapping at the Node and Edge response boundaries: malformed payloads return 400, while module-map misses throw and return 409.

This keeps status codes out of the ID validator and avoids allocating a result container on valid requests.

<!-- NEXT_JS_LLM -->
@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated
next-issue-60477-default Error Error Sep 2, 2026 10:48pm UTC
next-issue-60477-hybrid Error Error Sep 2, 2026 10:48pm UTC
next-issue-60477-repro Error Error Sep 2, 2026 10:48pm UTC

Derive the status of marked forwarded action responses from the original Server Action ID. This preserves 409 for well-formed stale references when a mixed-version worker returns 404, and prevents an unexpected upstream 200 from being treated as success.

<!-- NEXT_JS_LLM -->
@datadog-official

This comment has been minimized.

Require callers to classify unrecognized Server Action requests before handling the response. Header actions derive their status from the header ID, while MPA validation retains its explicit malformed-versus-missing classification.

<!-- NEXT_JS_LLM -->
Return generic, status-matched bodies for unrecognized Server Action requests. Malformed IDs receive an invalid-request body, while unavailable well-formed IDs receive an unavailable-action body.

<!-- NEXT_JS_LLM -->
Comment thread test/e2e/app-dir/actions-unrecognized/actions-unrecognized.test.ts Outdated
Run deployed MPA Server Action assertions for malformed and unavailable IDs. Keep only runtime log expectations local because deployment logs are unavailable.

<!-- NEXT_JS_LLM -->
@gnoff
gnoff merged commit 65c832c into canary Sep 3, 2026
128 checks passed
@gnoff
gnoff deleted the jstory/server-action-status-codes branch September 3, 2026 17:36
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.

2 participants