Fix incorrect import suggestion for ballerinax/client.config diagnostic#1559
Conversation
📝 WalkthroughWalkthroughAdds an exported constant Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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.tsor at the top ofrepair-utils.tsand 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
📒 Files selected for processing (2)
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.tsworkspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts
Outdated
Show resolved
Hide resolved
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts
Outdated
Show resolved
Hide resolved
055269a to
8fc32ac
Compare
There was a problem hiding this comment.
♻️ Duplicate comments (1)
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.ts (1)
142-142:⚠️ Potential issue | 🟡 MinorLog 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
📒 Files selected for processing (2)
workspaces/ballerina/ballerina-extension/src/features/ai/agent/tools/diagnostics-utils.tsworkspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/repair-utils.ts
Description
$Subject
Goals
Approach
UI Component Development
npm run storybookfrom the root directory to view current components.Manage Icons
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning
Summary by CodeRabbit