victor HF Staff commited on
Commit
1f7eb9d
·
1 Parent(s): 0d8e50a

Include 400 in policy error status codes

Browse files

Added HTTP 400 (Bad Request) to the list of status codes considered as policy errors in isPolicyError. This broadens the error handling to treat client-side validation issues as policy errors.

Files changed (1) hide show
  1. src/lib/server/router/endpoint.ts +2 -2
src/lib/server/router/endpoint.ts CHANGED
@@ -76,8 +76,8 @@ function extractUpstreamError(error: unknown): { message: string; statusCode?: n
76
  */
77
  function isPolicyError(statusCode?: number): boolean {
78
  if (!statusCode) return false;
79
- // 402: Payment Required, 401: Unauthorized, 403: Forbidden
80
- return statusCode === 402 || statusCode === 401 || statusCode === 403;
81
  }
82
 
83
  function stripReasoningBlocks(text: string): string {
 
76
  */
77
  function isPolicyError(statusCode?: number): boolean {
78
  if (!statusCode) return false;
79
+ // 400: Bad Request, 402: Payment Required, 401: Unauthorized, 403: Forbidden
80
+ return statusCode === 400 || statusCode === 401 || statusCode === 402 || statusCode === 403;
81
  }
82
 
83
  function stripReasoningBlocks(text: string): string {