Skip to content

Improve data service mediator and tryout#1526

Merged
ChinthakaJ98 merged 1 commit into
wso2:release-4.2.xfrom
ChinthakaJ98:dss-improvements
Jul 23, 2026
Merged

Improve data service mediator and tryout#1526
ChinthakaJ98 merged 1 commit into
wso2:release-4.2.xfrom
ChinthakaJ98:dss-improvements

Conversation

@ChinthakaJ98

@ChinthakaJ98 ChinthakaJ98 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@ChinthakaJ98
ChinthakaJ98 requested a review from rosensilva as a code owner July 6, 2026 15:19
@ChinthakaJ98 ChinthakaJ98 added Checks/Run MI UI Tests Force run MI UI tests Checks/Run LS Tests Force run LS tests labels Jul 6, 2026
@coderabbitai

coderabbitai Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 93198334-c8a5-4789-86d1-b091fbf5e04c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description only lists issues and a screenshot link; it omits the required template sections like Purpose, Goals, Approach, tests, and release notes. Fill in the repository template sections, especially Purpose, Goals, Approach, User stories, Release note, Documentation, tests, Security checks, and any applicable items.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Title check ✅ Passed The title is concise and matches the main theme of the PR: data service mediator and tryout improvements.
✨ 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: 3

🧹 Nitpick comments (5)
packages/mi-language-server/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/mediators/430/ui-schemas/dataServiceCall.json (1)

85-265: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicated DSSProperties sub-schema across three tables.

The DSSProperties nested table definition (propertyName/propertyValueType/propertyValue/propertyExpression) is repeated verbatim in singleOperations, batchOperations, and requestBoxoperations. If the schema format supports shared/referenced sub-definitions, extracting this would reduce duplication and future drift risk.

🤖 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
`@packages/mi-language-server/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/mediators/430/ui-schemas/dataServiceCall.json`
around lines 85 - 265, The DSSProperties nested table schema is duplicated
across multiple operation tables, so update the dataServiceCall.json schema to
reuse a shared sub-definition instead of repeating the same
propertyName/propertyValueType/propertyValue/propertyExpression block in
singleOperations, batchOperations, and requestBoxoperations. Extract that
repeated table into one reusable definition and reference it from each table’s
elements so future changes stay in sync; use the existing DSSProperties,
singleOperations, and batchOperations symbols to locate the repeated schema
sections.
packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts (1)

5933-5938: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Reuse a single proxy server instead of spinning up a new one per call.

Each call starts a new cors-anywhere server on a freshly-allocated port that is never closed. This mirrors the existing pattern in getOpenAPISpec/editOpenAPISpec, but now a third call site duplicates it. Repeated "Try it" clicks over a session will accumulate listening servers. Consider extracting a shared helper that lazily starts and reuses a single proxy instance across all three call sites.

🤖 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 `@packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts` around
lines 5933 - 5938, The proxy startup logic in the RPC manager creates a fresh
cors-anywhere server on every call, which can leak listeners across repeated
“Try it” actions. Extract the shared proxy setup used by getOpenAPISpec and
editOpenAPISpec into a reusable helper in rpc-manager.ts that lazily initializes
the proxy once and returns the same instance/port on subsequent calls. Update
this new call site to use that helper instead of directly calling getPortPromise
and cors_proxy.createServer.
packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java (1)

700-716: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Javadoc example doesn't match actual output.

Per WSO2 MI's documented naming convention, the runtime uses _<method><path> with no separator between method and path (e.g. _poststudent). This implementation matches that convention (correctly), but the method's own javadoc example — (path="student/{id}", method="PUT") yields _put_student_id — has a spurious underscore; the actual output would be _putstudent_id. Consider correcting the javadoc example to avoid confusing future maintainers.

🤖 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
`@packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java`
around lines 700 - 716, The Javadoc example in generateRequestName is
inconsistent with the actual naming logic and MI’s documented convention. Update
the example in AbstractResourceFinder.generateRequestName so it reflects the
real output from the current path/method transformation (no extra separator
between method and path), keeping the description aligned with the
implementation and the runtime naming rule.
packages/mi-diagram/src/components/Form/Keylookup/Keylookup.tsx (1)

279-293: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low value

Optional: skip the fetch when no data service is selected yet.

For filterType === "dsOperation" with no dataServiceName yet, an RPC round trip is still made (the server-side branch degrades gracefully to an empty/irrelevant lookup). Short-circuiting locally would avoid the unnecessary request while the user hasn't picked a data service.

♻️ Proposed optimization
+        if (filterType === "dsOperation" && !props.dataServiceName) {
+            setItems([]);
+            return;
+        }
+
         let resourceType: ResourceType | MultipleResourceType[];
🤖 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 `@packages/mi-diagram/src/components/Form/Keylookup/Keylookup.tsx` around lines
279 - 293, Short-circuit the lookup in Keylookup before calling
getAvailableResources when filterType is "dsOperation" and props.dataServiceName
is not set, so no unnecessary RPC request is made. Update the logic around the
resourceType selection and the
rpcClient.getMiDiagramRpcClient().getAvailableResources call to return early
with an empty result (or equivalent no-op state) in this case, while preserving
the existing behavior for bindToInbound, array filterType, and all other
resource lookups.
packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/pojo/DataServiceOperationResource.java (1)

22-28: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Consider setting a type on the resource.

DataServiceOperationResource only sets name; the base Resource.type field is left null. Callers in Keylookup.tsx use resource.type as the display-type for the dropdown item icon/badge, so dsOperation entries may render without a proper type indicator.

♻️ Proposed fix
 public class DataServiceOperationResource extends Resource {

     public DataServiceOperationResource(String name) {

         setName(name);
+        setType("dsOperation");
     }
 }
🤖 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
`@packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/pojo/DataServiceOperationResource.java`
around lines 22 - 28, `DataServiceOperationResource` only initializes the name,
so its inherited `Resource.type` remains null and downstream UI in
`Keylookup.tsx` cannot render the correct badge/icon. Update the
`DataServiceOperationResource` constructor to also assign an appropriate type
value for data service operations, using the existing
`Resource`/`DataServiceOperationResource` symbols to locate the initialization
point.
🤖 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 `@packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts`:
- Around line 5928-5932: The swagger fetch in getDataServiceOpenAPISpec
currently calls axios.get without a timeout or any error handling, so add a
timeout to the request and wrap the fetch in try/catch. Use the existing
getDataServiceOpenAPISpec method and the swaggerResponse/swaggerUrl flow to
catch network or host resolution failures, then surface a clear error back to
the caller instead of letting the request hang or fail silently.

In
`@packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java`:
- Around line 647-674: The getDataServiceOperations flow in
AbstractResourceFinder only handles IOException, so unchecked failures from
Utils.getDOMDocument or SyntaxTreeGenerator.buildTree can escape and break
availableResources. Broaden the try/catch in getDataServiceOperations to handle
unexpected parsing/runtime exceptions as well, and on any failure keep the
existing graceful behavior by logging a warning and returning the empty response
instead of propagating. Use the existing symbols Utils.getDOMDocument,
SyntaxTreeGenerator.buildTree, and LOGGER to locate the change.

In `@packages/mi-visualizer/src/RuntimeServicesPanel.tsx`:
- Around line 221-223: The onTryDataService handler in RuntimeServicesPanel
currently awaits getDataServiceOpenAPISpec without handling rejections, which
can surface as an unhandled promise rejection with no user feedback. Update
onTryDataService to catch failures from
rpcClient.getMiDiagramRpcClient().getDataServiceOpenAPISpec({ name }) and handle
them gracefully, using the existing RuntimeServicesPanel/“Try it” flow to show a
failure state or error message when the runtime service is unavailable.

---

Nitpick comments:
In `@packages/mi-diagram/src/components/Form/Keylookup/Keylookup.tsx`:
- Around line 279-293: Short-circuit the lookup in Keylookup before calling
getAvailableResources when filterType is "dsOperation" and props.dataServiceName
is not set, so no unnecessary RPC request is made. Update the logic around the
resourceType selection and the
rpcClient.getMiDiagramRpcClient().getAvailableResources call to return early
with an empty result (or equivalent no-op state) in this case, while preserving
the existing behavior for bindToInbound, array filterType, and all other
resource lookups.

In `@packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts`:
- Around line 5933-5938: The proxy startup logic in the RPC manager creates a
fresh cors-anywhere server on every call, which can leak listeners across
repeated “Try it” actions. Extract the shared proxy setup used by getOpenAPISpec
and editOpenAPISpec into a reusable helper in rpc-manager.ts that lazily
initializes the proxy once and returns the same instance/port on subsequent
calls. Update this new call site to use that helper instead of directly calling
getPortPromise and cors_proxy.createServer.

In
`@packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java`:
- Around line 700-716: The Javadoc example in generateRequestName is
inconsistent with the actual naming logic and MI’s documented convention. Update
the example in AbstractResourceFinder.generateRequestName so it reflects the
real output from the current path/method transformation (no extra separator
between method and path), keeping the description aligned with the
implementation and the runtime naming rule.

In
`@packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/pojo/DataServiceOperationResource.java`:
- Around line 22-28: `DataServiceOperationResource` only initializes the name,
so its inherited `Resource.type` remains null and downstream UI in
`Keylookup.tsx` cannot render the correct badge/icon. Update the
`DataServiceOperationResource` constructor to also assign an appropriate type
value for data service operations, using the existing
`Resource`/`DataServiceOperationResource` symbols to locate the initialization
point.

In
`@packages/mi-language-server/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/mediators/430/ui-schemas/dataServiceCall.json`:
- Around line 85-265: The DSSProperties nested table schema is duplicated across
multiple operation tables, so update the dataServiceCall.json schema to reuse a
shared sub-definition instead of repeating the same
propertyName/propertyValueType/propertyValue/propertyExpression block in
singleOperations, batchOperations, and requestBoxoperations. Extract that
repeated table into one reusable definition and reference it from each table’s
elements so future changes stay in sync; use the existing DSSProperties,
singleOperations, and batchOperations symbols to locate the repeated schema
sections.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1281521f-7195-4c08-9c28-fa0376c2bccd

📥 Commits

Reviewing files that changed from the base of the PR and between e79e248 and 8cad79b.

📒 Files selected for processing (20)
  • packages/mi-core/src/rpc-types/mi-diagram/index.ts
  • packages/mi-core/src/rpc-types/mi-diagram/rpc-type.ts
  • packages/mi-core/src/rpc-types/mi-diagram/types.ts
  • packages/mi-diagram/src/components/Form/FormGenerator.tsx
  • packages/mi-diagram/src/components/Form/GigaParamManager/ParameterManager.tsx
  • packages/mi-diagram/src/components/Form/Keylookup/Keylookup.tsx
  • packages/mi-extension/src/lang-client/ExtendedLanguageClient.ts
  • packages/mi-extension/src/rpc-managers/mi-diagram/rpc-handler.ts
  • packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts
  • packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/SynapseLanguageService.java
  • packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/mediatorService/mediators/DataServiceCallMediator.java
  • packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/AbstractResourceFinder.java
  • packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/pojo/DataServiceOperationResource.java
  • packages/mi-language-server/org.eclipse.lemminx/src/main/java/org/eclipse/lemminx/customservice/synapse/resourceFinder/pojo/ResourceParam.java
  • packages/mi-language-server/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/mediators/430/templates/dataServiceCall.mustache
  • packages/mi-language-server/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/mediators/430/ui-schemas/dataServiceCall.json
  • packages/mi-language-server/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/mediators/440/templates/dataServiceCall.mustache
  • packages/mi-language-server/org.eclipse.lemminx/src/main/resources/org/eclipse/lemminx/mediators/440/ui-schemas/dataServiceCall.json
  • packages/mi-rpc-client/src/rpc-clients/mi-diagram/rpc-client.ts
  • packages/mi-visualizer/src/RuntimeServicesPanel.tsx

Comment thread packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts
Comment thread packages/mi-visualizer/src/RuntimeServicesPanel.tsx
Comment thread packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts
Comment thread packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts Outdated
@arunans23

Copy link
Copy Markdown
Member

Shall we add screenshots to the PR description to show the rendering?

@ChinthakaJ98 ChinthakaJ98 removed Checks/Run MI UI Tests Force run MI UI tests Checks/Run LS Tests Force run LS tests labels Jul 14, 2026
Comment thread packages/mi-diagram/src/components/Form/Keylookup/Keylookup.tsx
Comment thread packages/mi-extension/src/rpc-managers/mi-diagram/rpc-manager.ts Outdated
@ChinthakaJ98
ChinthakaJ98 merged commit fff8099 into wso2:release-4.2.x Jul 23, 2026
7 checks passed
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