Skip to content

Prevent AsyncAPI definition request for API Products#1369

Open
fiend365gdsv wants to merge 2 commits into
wso2:mainfrom
fiend365gdsv:fix-skip-asyncapi-call-for-api-products
Open

Prevent AsyncAPI definition request for API Products#1369
fiend365gdsv wants to merge 2 commits into
wso2:mainfrom
fiend365gdsv:fix-skip-asyncapi-call-for-api-products

Conversation

@fiend365gdsv

Copy link
Copy Markdown

Fixes wso2/api-manager#5092

This PR prevents the Publisher deployment page from calling the AsyncAPI definition endpoint for API Products.

API Products do not carry AsyncAPI definitions, so calling restApi.getAsyncAPIDefinition(api.id) for API Products creates an unnecessary failed network request.

The fix adds an API Product guard while keeping the existing MCP Server guard unchanged.

Changes:

  • Added an API Product check using api.apiType === API.CONSTS.APIProduct
  • Skipped getAsyncAPIDefinition when the current entity is an API Product
  • Updated the React effect dependency list to include api.apiType and isMCPServer

Testing:

  • Verified the code change with git diff
  • Confirmed only Environments.jsx was changed

@CLAassistant

CLAassistant commented Jun 18, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@coderabbitai

coderabbitai Bot commented Jun 18, 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.yaml

Review profile: CHILL

Plan: Pro

Run ID: 293a6d75-efa6-4a02-a536-5de2c712d0ac

📥 Commits

Reviewing files that changed from the base of the PR and between 1177fe2 and 81ea8ac.

📒 Files selected for processing (1)
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx

📝 Walkthrough

Walkthrough

Environments.jsx adds a guard inside an existing useEffect that skips the restApi.getAsyncAPIDefinition call and external endpoint computation when the API is an APIProduct (api.apiType === API.CONSTS.APIProduct) or an MCP server. The effect's dependency array is expanded to include api.id, api.apiType, and isMCPServer.

Changes

APIProduct guard in Environments useEffect

Layer / File(s) Summary
APIProduct guard and dependency array update
portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx
Derives isAPIProduct from api.apiType at the top of the useEffect and adds it alongside the existing isMCPServer check to skip the async definition fetch and externalEnvWithEndpoints computation. The closing dependency array is updated to include api.id, api.apiType, and isMCPServer.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Prevent AsyncAPI definition request for API Products' directly and concisely describes the main change in the PR: adding a guard to prevent unnecessary AsyncAPI definition requests for API Products.
Description check ✅ Passed The PR description is clearly related to the changeset, explaining the fix, rationale, changes made, and testing performed, all aligned with preventing AsyncAPI requests for API Products.
Linked Issues check ✅ Passed The PR successfully addresses issue #5092 by adding an API Product type guard to skip AsyncAPI definition requests for API Products while preserving the MCP Server guard and updating dependency arrays.
Out of Scope Changes check ✅ Passed All changes are scoped to Environments.jsx and directly address the linked issue objective of preventing AsyncAPI requests for API Products without introducing unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ 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.

@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

🤖 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/Details/Environments/Environments.jsx`:
- Line 829: The useEffect dependency array for the effect that builds endpoint
mappings is missing `allExternalGateways`, which is a variable read within the
effect body at line 812. Add `allExternalGateways` to the dependency array
alongside api.id, api.apiType, and isMCPServer to ensure the effect re-runs
whenever external gateways are updated, preventing stale endpoint mappings.
🪄 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: 675106cb-37b6-4f5c-ae05-70ce71ea1ac3

📥 Commits

Reviewing files that changed from the base of the PR and between 5837654 and 1177fe2.

📒 Files selected for processing (1)
  • portals/publisher/src/main/webapp/source/src/app/components/Apis/Details/Environments/Environments.jsx

@fiend365gdsv

Copy link
Copy Markdown
Author

Hi team,

This PR is ready for review. The workflow is currently awaiting maintainer approval.

Thank you.

@sonarqubecloud

Copy link
Copy Markdown

@fiend365gdsv

Copy link
Copy Markdown
Author

Updated the dependency array to include allExternalGateways.

Thank you for the review.

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.

Unncessary call to /asyncapi when loading deployment page for API Products

2 participants