Skip to content

Show a specific error when agent creation hits the application limit#10538

Merged
RushanNanayakkara merged 3 commits into
wso2:masterfrom
RushanNanayakkara:fix-agent-wizard-app-limit-error
Jul 17, 2026
Merged

Show a specific error when agent creation hits the application limit#10538
RushanNanayakkara merged 3 commits into
wso2:masterfrom
RushanNanayakkara:fix-agent-wizard-app-limit-error

Conversation

@RushanNanayakkara

@RushanNanayakkara RushanNanayakkara commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Purpose

The agent creation wizard shows the generic "Something went wrong" / "Creating agent failed" alert for every failure — the catch block in add-agent-wizard.tsx discards the error response entirely.

When a user-serving agent cannot be created because the organization has reached its allowed application limit, the backend (with the related backend PRs) now returns HTTP 403 with scimType: applicationLimitReached. This PR makes the wizard detect that case and show a dedicated message: "Application limit reached — Agent application creation failed. Maximum application limit reached." All other failures keep the existing generic alert.

This follows the same pattern the add-user wizard uses for userLimitReached (403 + scimType check).

Related Issues

  • N/A

Related PRs

Checklist

  • e2e cypress tests locally verified. (for internal contributers)
  • Manual test round performed and verified.
  • UX/UI review done on the final implementation.
  • Documentation provided. (Add links if there are any)
  • Relevant backend changes deployed and verified
  • Unit tests provided.
  • Integration tests provided.

Security checks

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.
@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yml

Review profile: CHILL

Plan: Pro

Run ID: fb414fda-4d90-48c5-9905-82db8ceee6b4

📥 Commits

Reviewing files that changed from the base of the PR and between 4d35255 and bd56313.

📒 Files selected for processing (1)
  • .changeset/hungry-crabs-repair.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • .changeset/hungry-crabs-repair.md

📝 Walkthrough

Walkthrough

Agent creation now detects organization application-limit failures using a SCIM error type and displays a dedicated localized alert. The translation model, English text, and package changeset metadata are updated accordingly.

Changes

Agent application limit error

Layer / File(s) Summary
SCIM limit error detection
features/admin.agents.v1/constants/agents.ts, features/admin.agents.v1/components/wizards/add-agent-wizard.tsx
Defines the application-limit SCIM type and dispatches a dedicated alert for matching 403 responses, while preserving the generic fallback.
Localized alert contract and release metadata
modules/i18n/src/models/namespaces/agents-ns.ts, modules/i18n/src/translations/en-US/portals/agents.ts, .changeset/hungry-crabs-repair.md
Adds the limitReached alert shape and English translation, and records patch bumps for the agents, i18n, and console packages.
🚥 Pre-merge checks | ✅ 6
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: showing a specific application-limit error during agent creation.
Description check ✅ Passed The PR description matches the template well, with purpose, related links, checklist, and security sections mostly filled out.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Changeset Required ✅ Passed The PR diff includes .changeset/hungry-crabs-repair.md, and it lists @wso2is/admin.agents.v1, @wso2is/i18n, and @wso2is/console with patch bumps.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • 🛠️ create changeset

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai
coderabbitai Bot requested a review from pavinduLakshan July 15, 2026 04:47
@codecov

codecov Bot commented Jul 15, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 72.85%. Comparing base (d773ca4) to head (bd56313).
⚠️ Report is 48 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #10538   +/-   ##
=======================================
  Coverage   72.85%   72.85%           
=======================================
  Files         470      470           
  Lines       71228    71236    +8     
  Branches      240      240           
=======================================
+ Hits        51892    51900    +8     
  Misses      19225    19225           
  Partials      111      111           
Files with missing lines Coverage Δ
...ules/i18n/src/translations/en-US/portals/agents.ts 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@pavinduLakshan pavinduLakshan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why we didn't follow tier limit reached error handling done in other places for this fix?

@coderabbitai
coderabbitai Bot requested a review from pavinduLakshan July 15, 2026 09:53
(error as AxiosError<{ scimType?: string }>)?.response;

if (errorResponse?.status === 403
&& errorResponse?.data?.scimType === AGENT_APP_LIMIT_REACHED_SCIM_TYPE) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason why we can't check for the error code instead of checking the scimType, as we have done in other places? checking the scimType for this kind of error looks odd, IMO.

&& error?.response?.data?.code
=== RoleConstants.ERROR_CREATE_LIMIT_REACHED.getErrorCode()) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agent creation goes through the SCIM2 API (POST /scim2/Agents), not an internal server REST API. SCIM error responses only carry status, scimType, and detail — there is no code attribute in the payload, so an error-code check isn't possible here. scimType is SCIM's machine-readable error slot.

The role wizard example calls the Roles REST API, which does return a code field — a different API contract. For SCIM flows, this follows the existing precedent in this repo: the add-user wizard checks scimType === "userLimitReached" for the user creation limit (features/admin.users.v1/components/wizard/add-user-wizard.tsx). The backend counterpart (wso2-extensions/identity-inbound-provisioning-scim2#799) mirrors that existing userLimitReached mapping with applicationLimitReached.

@RushanNanayakkara

Copy link
Copy Markdown
Contributor Author

any reason why we didn't follow tier limit reached error handling done in other places for this fix?

The TierLimitReachErrorModal flow used in the application/role creation wizards keys off the REST API error code (APP-60503 / RLS-10004). Agent creation goes through the SCIM2 API, whose error responses don't carry an error code — only status, scimType, and detail. So the closest existing pattern for this flow is the add-user wizard's SCIM user-limit handling (403 + scimType: userLimitReached), which shows an alert — that's what this PR follows, with scimType: applicationLimitReached.

If the UX preference is the tier-limit modal instead of an alert, happy to switch — the detection logic stays the same.

Comment thread .changeset/hungry-crabs-repair.md
Comment thread .changeset/hungry-crabs-repair.md
Co-authored-by: Pavindu Lakshan <pavindulakshan@gmail.com>
@RushanNanayakkara
RushanNanayakkara merged commit ecf8b7f into wso2:master Jul 17, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants