Skip to content

Commit

Permalink
AAP-17358: 403 from CloudFlare mistaken as invalid Model ID (#1005)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Anstis <[email protected]>
  • Loading branch information
manstis and manstis authored Nov 6, 2023
1 parent 5f2b97e commit 1df57d0
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/features/lightspeed/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,22 @@ export class LightSpeedAPI {
"Too many requests to Ansible Lightspeed. Please try again after some time."
);
} else if (err?.response?.status === 400) {
vscode.window.showErrorMessage(
"Bad Request response. Please try again."
const responseErrorData = <AxiosError<{ message?: string }>>(
err?.response?.data
);
if (
responseErrorData &&
responseErrorData.hasOwnProperty("message") &&
responseErrorData.message?.includes("Cloudflare")
) {
vscode.window.showErrorMessage(
`Cloudflare rejected the request. Please contact your administrator.`
);
} else {
vscode.window.showErrorMessage(
"Bad Request response. Please try again."
);
}
} else if (err?.response?.status === 403) {
const responseErrorData = <AxiosError<{ message?: string }>>(
err?.response?.data
Expand Down

0 comments on commit 1df57d0

Please sign in to comment.