Surface backend validation error messages inline in the Create-API wizard - #1395
Surface backend validation error messages inline in the Create-API wizard#1395IsuruGunarathne wants to merge 12 commits into
Conversation
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughValidation 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. ChangesValidation Error Handling
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
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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 valueAlign error message fallback chain with other create-API components.
For consistency with
ProvideOpenAPI,ProvideAsyncAPI, andGenericEndpoint, consider falling back toerror.response?.body?.messageanderror.messagebefore applying the default generic message. This ensures users see relevant network or backend error strings whendescriptionis 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
📒 Files selected for processing (11)
portals/publisher/src/main/webapp/site/public/locales/en.jsonportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/AsyncAPI/Steps/ProvideAsyncAPI.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/DefaultAPIForm.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/ValidationResults.tsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/validationErrorUtils.test.tsportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/validationErrorUtils.tsportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/GraphQL/Steps/ProvideGraphQL.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/WSDL/Steps/ProvideWSDL.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/GenericEndpoint.jsxportals/publisher/src/main/webapp/source/src/app/components/MCPServers/Create/MCPServerCreateProxy.jsx
c5e22ad to
0329d6e
Compare
0329d6e to
ada7fc8
Compare
There was a problem hiding this comment.
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
📒 Files selected for processing (11)
portals/publisher/src/main/webapp/site/public/locales/en.jsonportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/AsyncAPI/Steps/ProvideAsyncAPI.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/DefaultAPIForm.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/ValidationResults.tsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/validationErrorUtils.test.tsportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/Components/validationErrorUtils.tsportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/GraphQL/Steps/ProvideGraphQL.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Create/WSDL/Steps/ProvideWSDL.jsxportals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Endpoints/GenericEndpoint.jsxportals/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
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
portals/publisher/src/main/webapp/source/src/app/components/Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsxportals/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
e62437c to
1496bd2
Compare
1496bd2 to
3135b2f
Compare
…t validation catch
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
3135b2f to
aace274
Compare
|



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
ValidationResultspanel and avalidationErrorUtilshelper (with unit tests) underApis/Create/Components, so every create flow renders backend validation errors the same way.ValidationResultspanel, matching the OpenAPI flow.GenericEndpoint,DefaultAPIForm, and the MCP server create proxy preserve the server-provided message in the validation catch path rather than overwriting it.en.json.Notes
This branch aggregates the UI error-handling work that was reviewed and merged into the
feature_nw_access_controlbranch (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.