From 8f5d3fd4df580bdc261480a14cb9d1d0ba981f62 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Wed, 15 Jul 2026 10:14:14 +0530 Subject: [PATCH 1/3] Show a specific error when agent creation hits the application limit The agent creation wizard showed the generic "Something went wrong" alert for every failure. When the backend rejects the creation because the organization's application limit is reached (HTTP 403 with scimType applicationLimitReached), show a dedicated limit-reached error message instead, following the pattern used by the add-user wizard for userLimitReached. --- .changeset/hungry-crabs-repair.md | 6 ++++ .../components/wizards/add-agent-wizard.tsx | 33 ++++++++++++++----- features/admin.agents.v1/constants/agents.ts | 6 ++++ .../i18n/src/models/namespaces/agents-ns.ts | 4 +++ .../src/translations/en-US/portals/agents.ts | 5 +++ 5 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 .changeset/hungry-crabs-repair.md diff --git a/.changeset/hungry-crabs-repair.md b/.changeset/hungry-crabs-repair.md new file mode 100644 index 00000000000..b4157e82709 --- /dev/null +++ b/.changeset/hungry-crabs-repair.md @@ -0,0 +1,6 @@ +--- +"@wso2is/admin.agents.v1": patch +"@wso2is/i18n": patch +--- + +Show a specific error message when agent creation fails because the organization's application limit has been reached, instead of the generic "Something went wrong" alert. diff --git a/features/admin.agents.v1/components/wizards/add-agent-wizard.tsx b/features/admin.agents.v1/components/wizards/add-agent-wizard.tsx index 5a567bca84e..a1dd30b8559 100644 --- a/features/admin.agents.v1/components/wizards/add-agent-wizard.tsx +++ b/features/admin.agents.v1/components/wizards/add-agent-wizard.tsx @@ -28,6 +28,7 @@ import { AppState } from "@wso2is/admin.core.v1/store"; import { AlertLevels, IdentifiableComponentInterface } from "@wso2is/core/models"; import { addAlert } from "@wso2is/core/store"; import { URLUtils } from "@wso2is/core/utils"; +import { AxiosError } from "axios"; import { CheckboxFieldAdapter, CheckboxGroupFieldAdapter, @@ -44,6 +45,7 @@ import { useDispatch, useSelector } from "react-redux"; import { Dispatch } from "redux"; import { Divider, Grid, Icon, Message } from "semantic-ui-react"; import { addAgent, updateAgentApplicationConfiguration } from "../../api/agents"; +import { AGENT_APP_LIMIT_REACHED_SCIM_TYPE } from "../../constants/agents"; import { AgentScimSchema, AgentType } from "../../models/agents"; import "./add-agent-wizard.scss"; @@ -168,18 +170,33 @@ const AddAgentWizard: FunctionComponent = ( setCreationResult(result); setIsShowingSuccessScreen(true); setIsSubmitting(false); - } catch (_err: unknown) { + } catch (error: unknown) { // On error, stay on form with the user's values. setIsShowingSuccessScreen(false); setCreationResult(null); setSubmittedValues(null); - dispatch( - addAlert({ - description: t("agents:wizard.alerts.error.description"), - level: AlertLevels.ERROR, - message: t("agents:wizard.alerts.error.message") - }) - ); + + const errorResponse: AxiosError<{ scimType?: string }>["response"] = + (error as AxiosError<{ scimType?: string }>)?.response; + + if (errorResponse?.status === 403 + && errorResponse?.data?.scimType === AGENT_APP_LIMIT_REACHED_SCIM_TYPE) { + dispatch( + addAlert({ + description: t("agents:wizard.alerts.limitReached.description"), + level: AlertLevels.ERROR, + message: t("agents:wizard.alerts.limitReached.message") + }) + ); + } else { + dispatch( + addAlert({ + description: t("agents:wizard.alerts.error.description"), + level: AlertLevels.ERROR, + message: t("agents:wizard.alerts.error.message") + }) + ); + } setIsSubmitting(false); } }; diff --git a/features/admin.agents.v1/constants/agents.ts b/features/admin.agents.v1/constants/agents.ts index e77f07b0e38..7466bf28b55 100644 --- a/features/admin.agents.v1/constants/agents.ts +++ b/features/admin.agents.v1/constants/agents.ts @@ -18,6 +18,12 @@ export const AGENT_SHARING_ERROR: string = "AGENT_SHARING_ERROR"; +/** + * SCIM `scimType` value returned when agent creation fails because the + * organization has reached its allowed application limit. + */ +export const AGENT_APP_LIMIT_REACHED_SCIM_TYPE: string = "applicationLimitReached"; + export const AGENT_FEATURE_DICTIONARY: Map = new Map() .set("AGENT_GROUPS", "agents.groups") .set("AGENT_SHARED_ACCESS", "agents.sharedAccess") diff --git a/modules/i18n/src/models/namespaces/agents-ns.ts b/modules/i18n/src/models/namespaces/agents-ns.ts index aceda2b80a1..52837708be3 100644 --- a/modules/i18n/src/models/namespaces/agents-ns.ts +++ b/modules/i18n/src/models/namespaces/agents-ns.ts @@ -116,6 +116,10 @@ export interface AgentsNS { message: string; description: string; }; + limitReached: { + message: string; + description: string; + }; clientIdFetchFailed: { message: string; description: string; diff --git a/modules/i18n/src/translations/en-US/portals/agents.ts b/modules/i18n/src/translations/en-US/portals/agents.ts index 3de3ee7f1bd..05a1760afa0 100644 --- a/modules/i18n/src/translations/en-US/portals/agents.ts +++ b/modules/i18n/src/translations/en-US/portals/agents.ts @@ -208,6 +208,11 @@ export const agents: AgentsNS = { error: { description: "Creating agent failed", message: "Something went wrong" + }, + limitReached: { + description: "You have reached the maximum number of applications allowed " + + "for this organization, so an application cannot be created for this agent.", + message: "Application limit reached" } }, buttons: { From 4d35255320d8a262756f67cc66eb58939c074833 Mon Sep 17 00:00:00 2001 From: rushannanayakkara Date: Wed, 15 Jul 2026 15:20:33 +0530 Subject: [PATCH 2/3] Shorten the agent application limit error description --- modules/i18n/src/translations/en-US/portals/agents.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/i18n/src/translations/en-US/portals/agents.ts b/modules/i18n/src/translations/en-US/portals/agents.ts index 05a1760afa0..6efba0c5e10 100644 --- a/modules/i18n/src/translations/en-US/portals/agents.ts +++ b/modules/i18n/src/translations/en-US/portals/agents.ts @@ -210,8 +210,7 @@ export const agents: AgentsNS = { message: "Something went wrong" }, limitReached: { - description: "You have reached the maximum number of applications allowed " - + "for this organization, so an application cannot be created for this agent.", + description: "Agent application creation failed. Maximum application limit reached.", message: "Application limit reached" } }, From bd563131b499b49255033ac7f8410db65baf3f63 Mon Sep 17 00:00:00 2001 From: Pavindu Lakshan Date: Thu, 16 Jul 2026 19:33:52 +0530 Subject: [PATCH 3/3] Apply suggestions from code review Co-authored-by: Pavindu Lakshan --- .changeset/hungry-crabs-repair.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/hungry-crabs-repair.md b/.changeset/hungry-crabs-repair.md index b4157e82709..dc05d579ebf 100644 --- a/.changeset/hungry-crabs-repair.md +++ b/.changeset/hungry-crabs-repair.md @@ -1,6 +1,7 @@ --- "@wso2is/admin.agents.v1": patch "@wso2is/i18n": patch +"@wso2is/console": patch --- Show a specific error message when agent creation fails because the organization's application limit has been reached, instead of the generic "Something went wrong" alert.