Skip to content

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

Open
IsuruGunarathne wants to merge 12 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 12 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.

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 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.

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 conversion of 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,WSDL}/Steps/*, portals/publisher/src/main/webapp/site/public/locales/en.json
Routes validation failures through structured state, resets errors when inputs change, preserves invalid uploaded files, and renders validation results.
Endpoint validation error fallbacks
portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/{AsyncAPI,GraphQL}/Steps/*, .../Components/DefaultAPIForm.jsx, .../Details/Endpoints/GenericEndpoint.jsx, .../MCPServers/Create/MCPServerCreateProxy.jsx, .../site/public/locales/en.json
Prioritizes response descriptions and messages, then raw errors and localized defaults, across endpoint validation 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: Return validation result or error details
  ProvideOpenAPI->>ValidationResults: Update validation state
  ValidationResults-->>User: Show validation status and errors
Loading

Suggested reviewers: ashera96, heshansudarshana, krishanx92

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: showing backend validation errors in the Create-API wizard.
Description check ✅ Passed The description directly explains the changes across create flows and endpoint validation paths.
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.

@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

@IsuruGunarathne
IsuruGunarathne force-pushed the feature_nw_access_control branch from c5e22ad to 0329d6e Compare July 20, 2026 05:01
@IsuruGunarathne
IsuruGunarathne force-pushed the feature_nw_access_control branch from 0329d6e to ada7fc8 Compare August 4, 2026 04:21

@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: 3

🤖 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/WSDL/Steps/ProvideWSDL.jsx`:
- Around line 162-171: Update the WSDL validation error handling around the
handler that sets field validity to preserve backend messages using description,
then response.body.message, then error.message precedence. Apply the same
fallback order in getValidationErrorsFromError within validationErrorUtils.ts,
while retaining the existing generic fallback and file/url validity behavior.
- Around line 204-209: Update the validation flow in the WSDL upload handler
around handleWSDLValidationResponse, handleWSDLValidationErrorResponse, and the
finally callback to track or cancel the active request. When reset() or an
input-type change makes the request stale, ignore its success, error, and
finally effects so it cannot restore the old file or validation errors; only
update inputValue and validation state for the current request.

In
`@portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Create/MCPServerCreateProxy.jsx`:
- Around line 234-243: Update the validation error handling around
setValidationError so message selection is performed independently of the
response-body condition. Prefer response.body.description,
response.body.message, then error.message, and use the localized connection
error only when all three are absent; preserve the resulting validation error
assignment.
🪄 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 Plus

Run ID: 0699ae03-e561-464a-8690-db819be66318

📥 Commits

Reviewing files that changed from the base of the PR and between 0329d6e and ada7fc8.

📒 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
🚧 Files skipped from review as they are similar to previous changes (7)
  • 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/AsyncAPI/Steps/ProvideAsyncAPI.jsx
  • portals/publisher/src/main/webapp/site/public/locales/en.json
  • 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/GraphQL/Steps/ProvideGraphQL.jsx
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx

@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: 2

🤖 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/WSDL/Steps/ProvideWSDL.jsx`:
- Around line 187-192: Update both the validateUrl and validateFileOrArchive
handlers to clear validationErrors to [] and reset isError before initiating
each new validation request, while preserving the existing request-id checks and
response handling.
- Around line 83-84: Update the validation flow using validationRequestId so
each validation request increments the ID when it starts, ensuring concurrent
requests receive unique tokens. Add an unmount cleanup that increments the ID to
invalidate pending callbacks without calling reset() or dispatching cleanup
state, and keep callback state updates guarded by the current request ID.
🪄 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 Plus

Run ID: 01497e94-8e9f-4320-b435-533e9b5d77e1

📥 Commits

Reviewing files that changed from the base of the PR and between ada7fc8 and 40f7388.

📒 Files selected for processing (2)
  • 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
🚧 Files skipped from review as they are similar to previous changes (1)
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx

@IsuruGunarathne
IsuruGunarathne force-pushed the feature_nw_access_control branch from e62437c to 1496bd2 Compare August 10, 2026 04:30
@IsuruGunarathne
IsuruGunarathne force-pushed the feature_nw_access_control branch from 1496bd2 to 3135b2f Compare August 19, 2026 05:24
JanithaSampathBandara and others added 8 commits August 20, 2026 09:42
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.
The OpenAPI and AsyncAPI Provide steps track independent url/file validity
keys; spread the existing state in the URL-validation catch so a URL error
does not clear a previously set file validation state.
- ProvideWSDL: track the active validation request so switching the input
  type mid-validation discards a stale in-flight response instead of
  restoring the previous file and its validation errors
- ProvideWSDL: align the file drop-zone layout with the OpenAPI step so the
  upload button sits on its own line instead of beside the "-or-" text
- ProvideOpenAPI: clear previous linter results when a new URL/file
  validation starts so they no longer persist after a failed validation
- increment the request id when each validation starts so concurrent
  requests receive unique tokens
- invalidate any in-flight validation on unmount so a late callback does
  not dispatch state after the step is gone
- clear previous validation errors when a new URL/file validation starts
  so a prior failure does not linger during the next request
@IsuruGunarathne
IsuruGunarathne force-pushed the feature_nw_access_control branch from 3135b2f to aace274 Compare August 20, 2026 04:12
@sonarqubecloud

Copy link
Copy Markdown

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.

4 participants