Skip to content

Comments

Fix duplicate identifier suggestion during new connection scenarios#691

Open
pasindufernando1 wants to merge 4 commits intoballerina-platform:1.6.xfrom
pasindufernando1:2275Fix
Open

Fix duplicate identifier suggestion during new connection scenarios#691
pasindufernando1 wants to merge 4 commits intoballerina-platform:1.6.xfrom
pasindufernando1:2275Fix

Conversation

@pasindufernando1
Copy link
Contributor

@pasindufernando1 pasindufernando1 commented Feb 12, 2026

Purpose

This PR fixes an issue where duplicate connector identifier names were being suggested, even when connection identifiers with the same name already existed.

The root cause was in the duplicate name detection logic. The getVisibleSymbols() was used without providing a valid position, which resulted in an empty symbol list and prevented proper duplicate detection.

To resolve this, for “NEW CONNECTION” scenarios, the implementation was updated to use moduleSymbols() instead of visibleSymbols(). This ensures that existing connector identifiers are correctly identified and prevents suggesting duplicate names.

Screen.Recording.2026-02-16.at.11.08.28.mov

Fixes : wso2/product-ballerina-integrator#2275

Copilot AI review requested due to automatic review settings February 12, 2026 05:39
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

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.

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:

  • 🔍 Trigger review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Comment @coderabbitai help to get the list of available commands and usage tips.

@pasindufernando1 pasindufernando1 changed the title Fix duplicate identifier during new connection scenarios Fix duplicate identifier suggestion during new connection scenarios Feb 12, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses duplicate connector identifier suggestions in NEW_CONNECTION template generation by improving the symbol set used for name de-duplication, and adds a regression test fixture to reproduce the issue.

Changes:

  • Add TemplateContext#getAllModuleSymbolNames() to fetch module-level symbols without requiring a cursor position.
  • Override NewConnectionBuilder#setReturnTypeProperties() to use module symbols for connection identifier de-duplication.
  • Add a new node-template test project + config to validate duplicate connection-name handling.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
.../node_template/source/duplicate_connector/connections.bal New test source with an existing module-level connection variable to force a duplicate-name scenario.
.../node_template/source/duplicate_connector/Ballerina.toml New test package metadata for the duplicate-connector fixture project.
.../node_template/config/new_duplicate_connection.json New node-template test case expecting a non-duplicating suggested connection identifier.
.../NewConnectionBuilder.java Switch NEW_CONNECTION return-variable naming to use module symbols instead of visible symbols.
.../NodeBuilder.java Add a module-symbol collection helper on TemplateContext.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@nipunayf nipunayf marked this pull request as draft February 12, 2026 15:43
@pasindufernando1 pasindufernando1 marked this pull request as ready for review February 16, 2026 05:34
properties()
.type(functionData.returnType(), false, functionData.importStatements(), hidden,
Property.RESULT_TYPE_LABEL)
.data(functionData.returnType(), context.getAllModuleSymbolNames(), label, doc);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have two concerns regarding this:

  1. If we create a connection locally, then locally declared connections are not accounted for.
  2. Whatever you’re doing here should also be applied to other module-level artifacts, such as model providers.

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