Skip to content

Fix incorrect import suggestion for ballerinax/client.config diagnostic#1559

Merged
xlight05 merged 1 commit intowso2:release/bi-1.8.xfrom
VellummyilumVinoth:fix-config
Feb 25, 2026
Merged

Fix incorrect import suggestion for ballerinax/client.config diagnostic#1559
xlight05 merged 1 commit intowso2:release/bi-1.8.xfrom
VellummyilumVinoth:fix-config

Conversation

@VellummyilumVinoth
Copy link
Contributor

@VellummyilumVinoth VellummyilumVinoth commented Feb 25, 2026

Description

$Subject

Goals

Describe the solutions that this feature/fix will introduce to resolve the problems described above

Approach

Describe how you are implementing the solutions. Include an animated GIF or screenshot if the change affects the UI (email documentation@wso2.com to review all UI text). Include a link to a Markdown file or Google doc if the feature write-up is too long to paste here.

UI Component Development

Specify the reason if following are not followed.

  • Added reusable UI components to the ui-toolkit. Follow the intructions when adding the componenent.
  • Use ui-toolkit components wherever possible. Run npm run storybook from the root directory to view current components.
  • Matches with the native VSCode look and feel.

Manage Icons

Specify the reason if following are not followed.

  • Added Icons to the font-wso2-vscode. Follow the instructions.

User stories

Summary of user stories addressed by this change>

Release note

Brief description of the new feature or bug fix as it will appear in the release notes

Documentation

Link(s) to product documentation that addresses the changes of this PR. If no doc impact, enter “N/A” plus brief explanation of why there’s no doc impact

Training

Link to the PR for changes to the training content in https://github.com/wso2/WSO2-Training, if applicable

Certification

Type “Sent” when you have provided new/updated certification questions, plus four answers for each question (correct answer highlighted in bold), based on this change. Certification questions/answers should be sent to certification@wso2.com and NOT pasted in this PR. If there is no impact on certification exams, type “N/A” and explain why.

Marketing

Link to drafts of marketing content that will describe and promote this feature, including product page changes, technical articles, blog posts, videos, etc., if applicable

Automation tests

  • Unit tests

    Code coverage information

  • Integration tests

    Details about the test cases and coverage

Security checks

Samples

Provide high-level details about the samples related to this feature

Related PRs

List any other related PRs

Migrations (if applicable)

Describe migration steps and platforms on which migration has been tested

Test environment

List all JDK versions, operating systems, databases, and browser/versions on which this feature/fix was tested

Learning

Describe the research phase and any blog posts, patterns, libraries, or add-ons you used to solve the problem.

Summary by CodeRabbit

  • Bug Fixes
    • Improved detection for invalid Ballerina config imports; users now receive a clear guidance message with the correct import syntax and instructions to re-run the tool.
  • Behavior Changes
    • When that specific invalid-import pattern is detected, dependency resolution is skipped for the affected diagnostic to avoid misleading suggestions; the issue is logged for visibility.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 25, 2026

📝 Walkthrough

Walkthrough

Adds an exported constant DIAGNOSTICS_TOOL_NAME and introduces guards in diagnostics post-processing to detect the invalid import pattern "ballerinax/.config as config", returning enriched diagnostics and skipping dependency-resolution logic when that pattern is present.

Changes

Cohort / File(s) Summary
Diagnostics utils
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts
Added export const DIAGNOSTICS_TOOL_NAME = "getCompilationErrors"; added post-processing early-return in checkCompilationErrors to detect BCE2003 errors containing ballerinax/.config as config, log a diagnostic, and return enriched diagnostics with corrective guidance instead of continuing normal enrichment.
Repair utils / dependency guard
workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts
Updated isModuleNotFoundDiagsExist to destructure diagnostic message and skip dependency-resolution processing when the message contains ballerinax/.config as config. No signature changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I found a glitch in import-land,
A dot and slash got out of hand.
I hopped in code, I left a clue,
Replace the import — then run anew. ✨

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is largely a template with placeholder sections and minimal actual content; critical sections like Goals, Approach, and test coverage are unfilled. Complete the template by providing: specific goals and approach describing the fix, test coverage details, documentation/release notes, and security checks to confirm no credentials were committed.
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing incorrect import suggestions for a specific diagnostic issue with ballerinax/client.config.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

Copy link
Contributor

@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

🧹 Nitpick comments (1)
workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts (1)

94-98: Extract the magic string "ballerinax/.config as config" to a shared constant.

The same literal is repeated in diagnostics-utils.ts (line 133). If the substring ever changes (e.g. compiler message wording is updated), both sites must be updated in sync. A single exported constant prevents drift.

♻️ Suggested refactor

Create a shared constant (e.g. in a sibling constants.ts or at the top of repair-utils.ts and re-export it):

+// In repair-utils.ts (or a shared constants file)
+export const INVALID_CONFIG_IMPORT_PATTERN = "ballerinax/.config as config";

Then consume it in both files:

-        if (message.includes("ballerinax/.config as config")) {
+        if (message.includes(INVALID_CONFIG_IMPORT_PATTERN)) {
-            d => d.code === "BCE2003" && d.message.includes("ballerinax/.config as config")
+            d => d.code === "BCE2003" && d.message.includes(INVALID_CONFIG_IMPORT_PATTERN)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts`
around lines 94 - 98, The literal "ballerinax/.config as config" is duplicated;
extract it into a shared exported constant (e.g., INVALID_CONFIG_IMPORT =
"ballerinax/.config as config") placed in a new sibling module (constants.ts) or
a common utilities module, export it, then import and use that constant in
repair-utils.ts (replace the inline string in the loop over uniqueDiagnosticMap)
and in diagnostics-utils.ts (replace the occurrence at the previous line ~133)
so both files reference the single exported symbol.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In
`@workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts`:
- Line 136: Update the log message in DiagnosticsUtils to reflect the actual
invalid import pattern being detected: replace the incorrect text
'ballerinax/client.config' with the compiler-emitted pattern 'ballerinax/.config
as config' (the message near the console.log in diagnostics-utils.ts that
currently reads "[DiagnosticsUtils] Detected invalid config import
'ballerinax/client.config'."). Ensure the new message exactly mentions
"ballerinax/.config as config" so it matches the detected pattern and the
Ballerina compiler output.
- Around line 139-141: Update the user-facing message string (the object
property message) so it correctly describes the invalid import that triggered
this branch and fixes the missing space: change the incorrect example text
`import ballerinax/client.config;` to `import ballerinax/.config as config;`
(the actual pattern that triggers this branch) and add a space between the
sentences so the concatenated template literal reads `...client.config;' After
applying the fix, call the getCompilationErrors tool again to verify there are
no remaining errors.`; ensure you only modify the message value referenced in
diagnostics-utils.ts (the message property shown in the diff).

---

Nitpick comments:
In
`@workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts`:
- Around line 94-98: The literal "ballerinax/.config as config" is duplicated;
extract it into a shared exported constant (e.g., INVALID_CONFIG_IMPORT =
"ballerinax/.config as config") placed in a new sibling module (constants.ts) or
a common utilities module, export it, then import and use that constant in
repair-utils.ts (replace the inline string in the loop over uniqueDiagnosticMap)
and in diagnostics-utils.ts (replace the occurrence at the previous line ~133)
so both files reference the single exported symbol.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f8453f6 and 055269a.

📒 Files selected for processing (2)
  • workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts

Copy link
Contributor

@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.

♻️ Duplicate comments (1)
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts (1)

142-142: ⚠️ Potential issue | 🟡 Minor

Log message still reports the source form instead of the detected diagnostic pattern.

Line 142 logs 'ballerinax/client.config' — the form the LLM wrote in source — but what was actually detected is the diagnostic substring "ballerinax/.config as config". Anyone reading the log while debugging will expect the logged value to match the detection predicate, not the inferred source construct.

🐛 Proposed fix
-            console.log(`[DiagnosticsUtils] Detected invalid client module import 'ballerinax/client.config'.`);
+            console.log(`[DiagnosticsUtils] Detected invalid config import pattern 'ballerinax/.config as config' in BCE2003 diagnostic.`);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts`
at line 142, The console.log in DiagnosticsUtils currently prints the source
form "'ballerinax/client.config'" instead of the actual detected diagnostic
pattern; update the log to emit the detected pattern (e.g., the diagnostic
substring "ballerinax/.config as config" or the variable holding it such as
detectedPattern or diagnostic.message) so the logged value matches the predicate
used for detection in diagnostics-utils.ts and aids debugging.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In
`@workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts`:
- Line 142: The console.log in DiagnosticsUtils currently prints the source form
"'ballerinax/client.config'" instead of the actual detected diagnostic pattern;
update the log to emit the detected pattern (e.g., the diagnostic substring
"ballerinax/.config as config" or the variable holding it such as
detectedPattern or diagnostic.message) so the logged value matches the predicate
used for detection in diagnostics-utils.ts and aids debugging.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 055269a and 8fc32ac.

📒 Files selected for processing (2)
  • workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts

@xlight05 xlight05 merged commit 0aa5333 into wso2:release/bi-1.8.x Feb 25, 2026
2 of 3 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