summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> 2025-05-21 15:53:07 +0100
committerGravatar GitHub <noreply@github.com> 2025-05-21 15:53:07 +0100
commite9fc456b58511da3ae2f932256217b3db4c42998 (patch)
tree8f385ca82a83a2ef8f1a1bfe17b92e5aecc840ec
parentf7f712cc29f80c4f8096489d7368c2fda223e097 (diff)
downloadastro-e9fc456b58511da3ae2f932256217b3db4c42998.tar.gz
astro-e9fc456b58511da3ae2f932256217b3db4c42998.tar.zst
astro-e9fc456b58511da3ae2f932256217b3db4c42998.zip
Expand ActionError codes to include IANA HTTP error codes (#13769)
Co-authored-by: Matt Kane <m@mk.gg>
-rw-r--r--.changeset/spotty-glasses-prove.md5
-rw-r--r--packages/astro/src/actions/runtime/virtual/shared.ts66
2 files changed, 63 insertions, 8 deletions
diff --git a/.changeset/spotty-glasses-prove.md b/.changeset/spotty-glasses-prove.md
new file mode 100644
index 000000000..6d355fa8f
--- /dev/null
+++ b/.changeset/spotty-glasses-prove.md
@@ -0,0 +1,5 @@
+---
+'astro': patch
+---
+
+Expand ActionError codes to include all IANA-registered HTTP error codes.
diff --git a/packages/astro/src/actions/runtime/virtual/shared.ts b/packages/astro/src/actions/runtime/virtual/shared.ts
index c9df7969f..479bab4e6 100644
--- a/packages/astro/src/actions/runtime/virtual/shared.ts
+++ b/packages/astro/src/actions/runtime/virtual/shared.ts
@@ -22,37 +22,87 @@ export const appendForwardSlash = _appendForwardSlash;
export const ACTION_ERROR_CODES = [
'BAD_REQUEST',
'UNAUTHORIZED',
+ 'PAYMENT_REQUIRED',
'FORBIDDEN',
'NOT_FOUND',
- 'TIMEOUT',
+ 'METHOD_NOT_ALLOWED',
+ 'NOT_ACCEPTABLE',
+ 'PROXY_AUTHENTICATION_REQUIRED',
+ 'REQUEST_TIMEOUT',
'CONFLICT',
+ 'GONE',
+ 'LENGTH_REQUIRED',
'PRECONDITION_FAILED',
- 'PAYLOAD_TOO_LARGE',
+ 'CONTENT_TOO_LARGE',
+ 'URI_TOO_LONG',
'UNSUPPORTED_MEDIA_TYPE',
+ 'RANGE_NOT_SATISFIABLE',
+ 'EXPECTATION_FAILED',
+ 'MISDIRECTED_REQUEST',
'UNPROCESSABLE_CONTENT',
+ 'LOCKED',
+ 'FAILED_DEPENDENCY',
+ 'TOO_EARLY',
+ 'UPGRADE_REQUIRED',
+ 'PRECONDITION_REQUIRED',
'TOO_MANY_REQUESTS',
- 'CLIENT_CLOSED_REQUEST',
+ 'REQUEST_HEADER_FIELDS_TOO_LARGE',
+ 'UNAVAILABLE_FOR_LEGAL_REASONS',
'INTERNAL_SERVER_ERROR',
+ 'NOT_IMPLEMENTED',
+ 'BAD_GATEWAY',
+ 'SERVICE_UNAVAILABLE',
+ 'GATEWAY_TIMEOUT',
+ 'HTTP_VERSION_NOT_SUPPORTED',
+ 'VARIANT_ALSO_NEGOTIATES',
+ 'INSUFFICIENT_STORAGE',
+ 'LOOP_DETECTED',
+ 'NETWORK_AUTHENTICATION_REQUIRED',
] as const;
export type ActionErrorCode = (typeof ACTION_ERROR_CODES)[number];
const codeToStatusMap: Record<ActionErrorCode, number> = {
- // Implemented from tRPC error code table
- // https://trpc.io/docs/server/error-handling#error-codes
+ // Implemented from IANA HTTP Status Code Registry
+ // https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
BAD_REQUEST: 400,
UNAUTHORIZED: 401,
+ PAYMENT_REQUIRED: 402,
FORBIDDEN: 403,
NOT_FOUND: 404,
- TIMEOUT: 405,
+ METHOD_NOT_ALLOWED: 405,
+ NOT_ACCEPTABLE: 406,
+ PROXY_AUTHENTICATION_REQUIRED: 407,
+ REQUEST_TIMEOUT: 408,
CONFLICT: 409,
+ GONE: 410,
+ LENGTH_REQUIRED: 411,
PRECONDITION_FAILED: 412,
- PAYLOAD_TOO_LARGE: 413,
+ CONTENT_TOO_LARGE: 413,
+ URI_TOO_LONG: 414,
UNSUPPORTED_MEDIA_TYPE: 415,
+ RANGE_NOT_SATISFIABLE: 416,
+ EXPECTATION_FAILED: 417,
+ MISDIRECTED_REQUEST: 421,
UNPROCESSABLE_CONTENT: 422,
+ LOCKED: 423,
+ FAILED_DEPENDENCY: 424,
+ TOO_EARLY: 425,
+ UPGRADE_REQUIRED: 426,
+ PRECONDITION_REQUIRED: 428,
TOO_MANY_REQUESTS: 429,
- CLIENT_CLOSED_REQUEST: 499,
+ REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
+ UNAVAILABLE_FOR_LEGAL_REASONS: 451,
INTERNAL_SERVER_ERROR: 500,
+ NOT_IMPLEMENTED: 501,
+ BAD_GATEWAY: 502,
+ SERVICE_UNAVAILABLE: 503,
+ GATEWAY_TIMEOUT: 504,
+ HTTP_VERSION_NOT_SUPPORTED: 505,
+ VARIANT_ALSO_NEGOTIATES: 506,
+ INSUFFICIENT_STORAGE: 507,
+ LOOP_DETECTED: 508,
+ NETWORK_AUTHENTICATION_REQUIRED: 511,
};
const statusToCodeMap: Record<number, ActionErrorCode> = Object.entries(codeToStatusMap).reduce(