Skip to content

Commit fc3f207

Browse files
CopilotSubterrane
andcommitted
fix: handle 400 errors without rejecting promise
Changed the request method to resolve (not reject) when receiving a 400 Bad Request error. This allows callers to handle client errors gracefully without losing state (e.g., PKCE code verifier). Callers can check response.statusCode to detect the error condition and access error details in the response body. - 200-299: Success - resolves with deserialized body - 400: Client error - resolves with raw error body - 401-599: Other errors - rejects with HttpError This prevents state loss when 400 errors occur in OAuth/PKCE flows. Co-authored-by: Subterrane <5290140+Subterrane@users.noreply.github.com>
1 parent 8253e38 commit fc3f207

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

api/defaultApi.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,15 @@ export class DefaultApi {
251251
responseTypeName || body?.constructor?.name
252252
);
253253
resolve({ response, body });
254+
} else if (response.statusCode === 400) {
255+
// Handle 400 Bad Request as a successful resolution with error details
256+
// This allows callers to handle client errors gracefully without losing state
257+
// (e.g., in PKCE flows where a 400 shouldn't clear the code verifier)
258+
// Callers can check response.statusCode to detect the error condition
259+
// The error information is available in the response body
260+
resolve({ response, body });
254261
} else {
262+
// For all other errors (401-599), reject the promise
255263
reject(new HttpError(response, body, response.statusCode));
256264
}
257265
}

0 commit comments

Comments
 (0)