diff --git a/src/features/lightspeed/handle_api_error.ts b/src/features/lightspeed/handle_api_error.ts index 0921c3fd6..bdc006a6a 100644 --- a/src/features/lightspeed/handle_api_error.ts +++ b/src/features/lightspeed/handle_api_error.ts @@ -43,6 +43,12 @@ export function retrieve_error(err: AxiosError): string { "permission_denied__org_not_ready_because_wca_not_configured" ) { return `Contact your administrator to configure IBM watsonx Code Assistant model settings for your organization.`; + } else if ( + responseErrorData && + responseErrorData.hasOwnProperty("code") && + responseErrorData.code === "permission_denied__user_trial_expired" + ) { + return `Your trial to the generative AI model has expired. Refer to your IBM Cloud Account to re-enable access to the IBM watsonx Code Assistant.`; } else { return `User not authorized to access Ansible Lightspeed.`; } diff --git a/test/units/lightspeed/handle_api_error.test.ts b/test/units/lightspeed/handle_api_error.test.ts index aa701a477..50364584a 100644 --- a/test/units/lightspeed/handle_api_error.test.ts +++ b/test/units/lightspeed/handle_api_error.test.ts @@ -83,6 +83,17 @@ describe("testing the error handling", () => { `You do not have a licensed seat for Ansible Lightspeed and your organization is using the paid commercial service. Contact your Red Hat Organization's administrator for more information on how to get a licensed seat.` ); }); + it("err Forbidden - Trial expired", () => { + const msg = retrieve_error( + create_error(403, { + code: "permission_denied__user_trial_expired", + }) + ); + assert.equal( + msg, + `Your trial to the generative AI model has expired. Refer to your IBM Cloud Account to re-enable access to the IBM watsonx Code Assistant.` + ); + }); it("err Forbidden - WCA not ready", () => { const msg = retrieve_error( create_error(403, {