Skip to content

Surface backend validation error messages inline in the Create-API wizard#1395

Open
IsuruGunarathne wants to merge 11 commits into
wso2:mainfrom
IsuruGunarathne:feature_nw_access_control
Open

Surface backend validation error messages inline in the Create-API wizard#1395
IsuruGunarathne wants to merge 11 commits into
wso2:mainfrom
IsuruGunarathne:feature_nw_access_control

Conversation

@IsuruGunarathne

Copy link
Copy Markdown
Contributor

Surface backend validation error messages inline in the Create-API wizard

Purpose

When a submitted API definition or endpoint is rejected by the backend, the Create-API wizard previously either swallowed the server's message or replaced it with a generic one, so the user could not tell why the input was rejected. This change surfaces the backend's validation error message inline, next to the relevant step, across every definition type in the wizard.

What changed

  • Introduced a shared ValidationResults panel and a validationErrorUtils helper (with unit tests) under Apis/Create/Components, so every create flow renders backend validation errors the same way.
  • OpenAPI — the Provide-OpenAPI step now displays the rejection message returned by the backend instead of a generic failure.
  • WSDL — the Provide-WSDL step renders validation errors through the same shared ValidationResults panel, matching the OpenAPI flow.
  • AsyncAPI and GraphQL provide steps surface backend validation messages consistently.
  • Endpoint validationGenericEndpoint, DefaultAPIForm, and the MCP server create proxy preserve the server-provided message in the validation catch path rather than overwriting it.
  • Added the supporting locale strings to en.json.

Notes

This branch aggregates the UI error-handling work that was reviewed and merged into the feature_nw_access_control branch (the base error-handling improvements plus the inline error-surfacing on top). It pairs with the corresponding backend validation changes; the UI degrades gracefully if the backend returns a generic message.

JanithaSampathBandara and others added 11 commits June 5, 2026 10:41
…i-error-handling

Improvement UI error handling
When validate-openapi rejects a definition by URL/file (HTTP 400 with a
reason in the response body), the wizard's .catch handlers dropped the
backend reason to console.error and showed only a generic "validation
failed" message - the Validation Errors card stayed empty. A 400 was thus
surfaced less prominently than a 200 isValid:false, which renders the
backend errors array in the card.

Add getValidationErrorsFromError() to thread the backend
response.body.description into setValidationErrors() across the URL and file
(API + MCP) rejection paths, so a rejected validation shows as prominently
as the isValid:false path. Also clear stale validation errors on
file-validation success. Errors without a backend description return [] and
keep the existing generic-message fallback.

Adds a unit test for the helper.
… OpenAPI flow)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eate step

Move validationErrorUtils and ValidationResults out of Create/OpenAPI/Steps
into the shared Create/Components directory so both the OpenAPI and WSDL
create flows consume them from a common location, and update the imports in
ProvideOpenAPI and ProvideWSDL accordingly.

WSDL Provide step:
- Make the input row full-width and drop the container spacing so the drop
  zone and the validation results panel match the OpenAPI step layout.
- Reset the validation state (results panel, inline error and selected input)
  when the Input Type or Implementation Type changes, matching the OpenAPI
  flow, so a stale error no longer lingers after switching modes.
…ontrol-ui

Surface backend validation error messages inline in the Create-API wizard
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ IsuruGunarathne
✅ PasanT9
❌ JanithaSampathBandara


JanithaSampathBandara seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Validation handling now surfaces backend descriptions and messages across API, OpenAPI, WSDL, GraphQL, AsyncAPI, endpoint, and MCP server flows. OpenAPI and WSDL validation results use shared structured error rendering, with localized fallback messages and expanded validation state management.

Changes

Validation Error Handling

Layer / File(s) Summary
Shared validation result contract
portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/validationErrorUtils.ts, .../validationErrorUtils.test.ts, .../ValidationResults.tsx
Adds and tests a helper that converts backend validation descriptions into card entries, and updates the severity-map import path.
OpenAPI and WSDL validation flows
portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx, .../WSDL/Steps/ProvideWSDL.jsx, site/public/locales/en.json
Routes OpenAPI and WSDL validation failures through structured validation state, resets errors when inputs change, preserves invalid uploaded files, and renders validation results with localized titles and messages.
Endpoint validation error fallbacks
portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/{AsyncAPI,GraphQL}/Steps/*, .../Components/DefaultAPIForm.jsx, portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/GenericEndpoint.jsx, portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Create/MCPServerCreateProxy.jsx, site/public/locales/en.json
Prioritizes response descriptions and messages, then raw errors and localized defaults, across endpoint validation and testing flows.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant ProvideOpenAPI
  participant ValidationAPI
  participant ValidationResults
  User->>ProvideOpenAPI: Submit URL or file
  ProvideOpenAPI->>ValidationAPI: Validate API definition
  ValidationAPI-->>ProvideOpenAPI: Success or backend error details
  ProvideOpenAPI->>ValidationResults: Update validation state
  ValidationResults-->>User: Show validation status and errors
Loading

Possibly related PRs

  • wso2/apim-apps#1374: Introduces the same validation error helper and overlapping OpenAPI/WSDL integration changes.

Suggested reviewers: ashera96, hisanhunais, rakhitharr

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: surfacing backend validation messages inline in the Create-API wizard.
Description check ✅ Passed The description matches the changeset and correctly describes the shared validation UI, error utilities, and flow updates.
Docstring Coverage ✅ Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/WSDL/Steps/ProvideWSDL.jsx (1)

158-164: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Align error message fallback chain with other create-API components.

For consistency with ProvideOpenAPI, ProvideAsyncAPI, and GenericEndpoint, consider falling back to error.response?.body?.message and error.message before applying the default generic message. This ensures users see relevant network or backend error strings when description is missing.

♻️ Proposed refactor
-        let message = intl.formatMessage({
-            id: 'Apis.Create.WSDL.validation.error.response',
-            defaultMessage: 'Error occurred during validation',
-        });
-        if (error.response?.body?.description) {
-            message = error.response.body.description;
-        }
+        const message = error.response?.body?.description
+            || error.response?.body?.message
+            || error.message
+            || intl.formatMessage({
+                id: 'Apis.Create.WSDL.validation.error.response',
+                defaultMessage: 'Error occurred during validation',
+            });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/WSDL/Steps/ProvideWSDL.jsx`
around lines 158 - 164, Update the validation error handling in ProvideWSDL to
use the same fallback chain as ProvideOpenAPI, ProvideAsyncAPI, and
GenericEndpoint: prefer error.response.body.description, then
error.response.body.message, then error.message, and finally the existing
localized generic message.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx`:
- Line 141: Preserve existing validity state in the URL-validation catch blocks
by spreading isValid before setting the URL error. Update ProvideOpenAPI.jsx
lines 141-141, ProvideAsyncAPI.jsx lines 229-236, and ProvideGraphQL.jsx lines
178-181 so each setValidity call uses the existing isValid state alongside its
current url error payload.

---

Nitpick comments:
In
`@portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/WSDL/Steps/ProvideWSDL.jsx`:
- Around line 158-164: Update the validation error handling in ProvideWSDL to
use the same fallback chain as ProvideOpenAPI, ProvideAsyncAPI, and
GenericEndpoint: prefer error.response.body.description, then
error.response.body.message, then error.message, and finally the existing
localized generic message.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bce3568d-92a0-40dc-86cf-412e5630b2e2

📥 Commits

Reviewing files that changed from the base of the PR and between 7b680fc and 9c7ad2d.

📒 Files selected for processing (11)
  • portals/publisher/src/main/webapp/site/public/locales/en.json
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/AsyncAPI/Steps/ProvideAsyncAPI.jsx
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/DefaultAPIForm.jsx
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/ValidationResults.tsx
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/validationErrorUtils.test.ts
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/validationErrorUtils.ts
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/GraphQL/Steps/ProvideGraphQL.jsx
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/WSDL/Steps/ProvideWSDL.jsx
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/GenericEndpoint.jsx
  • portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Create/MCPServerCreateProxy.jsx

id: 'Apis.Create.OpenAPI.Steps.ProvideOpenAPI.url.validation.error',
defaultMessage: 'Failed to validate the OpenAPI URL. Please try again.',
});
setValidity({ url: { message: errorMessage } });

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Preserve existing validation state when setting URL errors.

In the previous implementations, these .catch() blocks used the object spread ...isValid to update the URL error without erasing other tracked validity states (such as isValid.file). The recent refactors dropped this spread, which can cause subtle state-loss glitches when users toggle between input modes.

Please restore the ...isValid spread in these validation catch blocks:

  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx#L141-L141: setValidity({ ...isValid, url: { message: errorMessage } });
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/AsyncAPI/Steps/ProvideAsyncAPI.jsx#L229-L236: Update to setValidity({ ...isValid, url: { ... } });
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/GraphQL/Steps/ProvideGraphQL.jsx#L178-L181: Update to setValidity({ ...isValid, url: { ... } });
📍 Affects 3 files
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx#L141-L141 (this comment)
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/AsyncAPI/Steps/ProvideAsyncAPI.jsx#L229-L236
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/GraphQL/Steps/ProvideGraphQL.jsx#L178-L181
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx`
at line 141, Preserve existing validity state in the URL-validation catch blocks
by spreading isValid before setting the URL error. Update ProvideOpenAPI.jsx
lines 141-141, ProvideAsyncAPI.jsx lines 229-236, and ProvideGraphQL.jsx lines
178-181 so each setValidity call uses the existing isValid state alongside its
current url error payload.

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