Skip to content

Commit

Permalink
AAP-18228: Handle user's trial expiry (#1037)
Browse files Browse the repository at this point in the history
* AAP-18228: Handle user's trial expiry

* Message

* Unit tests and corrected error messge

---------

Co-authored-by: Roger Martinez <roger600@gmail.com>
Co-authored-by: Ganesh Nalawade <ganesh634@gmail.com>
  • Loading branch information
3 people authored Jan 5, 2024
1 parent b2db7d0 commit 3eac1fc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/features/lightspeed/handle_api_error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`;
}
Expand Down
11 changes: 11 additions & 0 deletions test/units/lightspeed/handle_api_error.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down

0 comments on commit 3eac1fc

Please sign in to comment.