Skip to content

Improve UI error handling for SSRF-blocked URL scenarios#1344

Open
JanithaSampathBandara wants to merge 4 commits into
wso2:mainfrom
JanithaSampathBandara:fix/ssrf-ui-error-handling
Open

Improve UI error handling for SSRF-blocked URL scenarios#1344
JanithaSampathBandara wants to merge 4 commits into
wso2:mainfrom
JanithaSampathBandara:fix/ssrf-ui-error-handling

Conversation

@JanithaSampathBandara
Copy link
Copy Markdown

Purpose

This PR adds UI improvements related to the outbound request security feature introduced to mitigate Server-Side Request Forgery (SSRF) attacks.

Previously, outbound request validation failures could surface as generic HTTP errors in the UI, making it difficult for users to understand the actual validation issue.

This improvement provides clearer validation feedback for blocked or untrusted remote URLs.


Goals

  • Display meaningful validation errors in the UI
  • Avoid generic HTTP 500 error messages where possible
  • Improve endpoint validation user experience
  • Preserve existing successful validation flows

Approach

Updated UI components responsible for endpoint validation to properly extract and display backend validation errors returned by outbound request security checks.

Improved:

  • Backend error extraction
  • Error message rendering
  • Validation feedback consistency

Handled scenarios including:

  • Untrusted URL validation failures
  • Private/internal network access blocking
  • Tenant allowlist validation failures
  • Platform-level policy validation failures

Release Note

Improved UI error handling for outbound request security validation failures.


Testing

Verified:

  • Endpoint validation with blocked URL
  • Endpoint validation with private IP URL
  • Endpoint validation with non-allowlisted host
  • Backend validation error rendering
  • Existing successful validation flows remain unaffected

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 17808fea-d154-47e1-916d-da5708121844

📥 Commits

Reviewing files that changed from the base of the PR and between 79df8bc and 68aed1e.

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

📝 Walkthrough

Walkthrough

This PR changes validation and endpoint-test error handling across five components to prefer server response body fields (description, message) when deriving user-facing error text, falling back to error.message or i18n fallback where appropriate.

Changes

Error Message Enrichment in Validation

Layer / File(s) Summary
AsyncAPI Validation
portals/publisher/.../Apis/Create/AsyncAPI/Steps/ProvideAsyncAPI.jsx
URL validation error message now extracted from error.response?.body?.description, fallback to error.response?.body?.message, then error.message.
GraphQL Validation
portals/publisher/.../Apis/Create/GraphQL/Steps/ProvideGraphQL.jsx
Invalid response handling prioritizes body fields with endpoint-/URL-aware fallback text; request error handler uses optional-chained response body fields with error.message fallback.
OpenAPI Validation
portals/publisher/.../Apis/Create/OpenAPI/Steps/ProvideOpenAPI.jsx
Shared handleValidationError prefers error.response?.body?.description, then .message, then error.message; MCP and non‑MCP rejection handlers use it.
Endpoint Testing
portals/publisher/.../Apis/Create/Components/DefaultAPIForm.jsx
Added .catch(...) handler to extract statusCode from response body fields, set isErrorCode=true and mark endpoint invalid; .finally(...) still clears updating state.
MCP Server Validation
portals/publisher/.../MCPServers/Create/MCPServerCreateProxy.jsx
Validation error message now derived from error.response.body.description or error.response.body.message, falling back to an i18n default instead of a fixed string.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the primary change: improving UI error handling for SSRF-blocked URL scenarios, which matches the core objective of extracting and displaying backend validation errors.
Description check ✅ Passed The description comprehensively explains the purpose, goals, approach, and testing of the changes, directly relating to the changeset which updates error handling across multiple validation components.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 and usage tips.

@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 sign our Contributor License Agreement before we can accept your contribution.


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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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/OpenAPI/Steps/ProvideOpenAPI.jsx`:
- Around line 165-171: In the MCP server URL validation catch block inside
ProvideOpenAPI.jsx update the error selection so it mirrors the non‑MCP path:
when calling setValidity({ url: { message: ... } }) use the chain
error.response?.body?.description || error.response?.body?.message ||
error.message instead of jumping directly from description to error.message;
locate the catch handler that calls setValidity, onValidate(false),
setIsValidating(false) and replace the message expression to include the
intermediate error.response?.body?.message fallback.

In
`@portals/publisher/src/main/webapp/source/src/app/components/MCPServers/Create/MCPServerCreateProxy.jsx`:
- Around line 234-239: The fallback hardcoded string assigned to errorMessage
bypasses i18n; replace the literal 'Failed to validate MCP Server URL' with a
call to intl.formatMessage (using an existing message id or add a new one) when
constructing errorMessage so that setValidationError receives a localized string
(ensure intl is in scope in MCPServerCreateProxy.jsx and keep the existing
precedence of error.response.body.description || error.response.body.message ||
intl.formatMessage(...)); this will ensure the validationError shown to the user
is localized.
🪄 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: ba807d46-e7f5-49af-bea9-aa4026db48d6

📥 Commits

Reviewing files that changed from the base of the PR and between bcc9a00 and 79df8bc.

📒 Files selected for processing (5)
  • 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/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/MCPServers/Create/MCPServerCreateProxy.jsx

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 9, 2026

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.

2 participants