Skip to content

Conversation

@madushajg
Copy link
Member

@madushajg madushajg commented Dec 2, 2025

Purpose

Address: wso2/product-ballerina-integrator#2038

$title due to BinaryMuse/toml-node#51

Summary by CodeRabbit

  • Chores

    • Swapped TOML library across Ballerina and BI extensions to a maintained parser.
    • Adjusted related interfaces to use safer, partial configuration shapes.
  • Bug Fixes

    • More robust TOML parsing with safer defaults and graceful fallbacks for missing or malformed config.
    • Improved reliability when reading and serializing project/workspace configuration data.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 2, 2025

Walkthrough

Replaced the TOML library toml with @iarna/toml across Ballerina and BI workspaces, updated package.jsons, adjusted imports/usages (parse/stringify), and changed several TOML-related return types to Partial<...> with safer property access.

Changes

Cohort / File(s) Summary
Dependency updates
workspaces/ballerina/ballerina-extension/package.json, workspaces/bi/bi-extension/package.json
Removed toml@^3.0.0 and added @iarna/toml@^2.2.5 in dependencies.
Parsing utilities (Ballerina)
workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts, workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts
Switched imports to @iarna/toml; replaced toml.parse with parse(...); added stringify/stringify.value usage where applicable; ensured explicit fallback on parse errors.
Config & workspace helpers (Ballerina)
workspaces/ballerina/ballerina-extension/src/utils/bi.ts, workspaces/ballerina/ballerina-extension/src/utils/config.ts
Switched to @iarna/toml; cast parsed results to Partial<...> and used optional chaining/nullish coalescing when accessing workspace/package fields.
RPC managers (Ballerina)
workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts, workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts
Replaced TOML import with @iarna/toml; added PackageTomlValues import where used; changed getCurrentProjectTomlValues return type to Promise<Partial<PackageTomlValues>> and used safe access for parsed values.
RPC client (Ballerina)
workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts
Updated getCurrentProjectTomlValues return type to Promise<Partial<PackageTomlValues>>.
BI extension utilities
workspaces/bi/bi-extension/src/utils.ts
Switched TOML import to @iarna/toml; cast parsed TOML to Partial<...> and updated exported/internal function return types accordingly.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

  • Check all call sites of changed return types (getCurrentProjectTomlValues, getWorkspaceTomlValues) for handling of possibly missing fields.
  • Verify stringify/stringify.value output in tracing utilities matches expected TOML formatting used elsewhere.
  • Confirm package.json dependency replace does not break build/resolution in workspaces.

Possibly related PRs

Suggested reviewers

  • hevayo
  • gigara

Poem

🐰 I swapped the old toml for a fresher tune,
Parsed with care beneath the moon.
Partial fields snug in my paw,
Optional chains keep bugs at bay—huzzah! ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete and lacks most required template sections like Goals, Approach, Documentation, Testing, and Security checks. Fill out the required template sections, particularly Goals, Approach, Documentation, Automation tests, and Security checks sections to provide comprehensive context.
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing the legacy toml package with @iarna/toml across the codebase.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fc902e1 and 1d2ae7f.

⛔ Files ignored due to path filters (1)
  • common/config/rush/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • workspaces/ballerina/ballerina-extension/package.json (1 hunks)
  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts (2 hunks)
  • workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts (2 hunks)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts (3 hunks)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts (1 hunks)
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts (3 hunks)
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts (2 hunks)
  • workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts (1 hunks)
  • workspaces/bi/bi-extension/package.json (1 hunks)
  • workspaces/bi/bi-extension/src/utils.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts
  • workspaces/bi/bi-extension/src/utils.ts
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/**/*.config.{js,ts} : Use minimatch-compatible glob patterns for file matching in build and test configuration files
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Define all constants (node types, sizing, spacing) in src/resources/constants.ts and import them where needed instead of hardcoding values
📚 Learning: 2025-11-10T15:05:11.309Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:224-242
Timestamp: 2025-11-10T15:05:11.309Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate VS Code extensions that are packaged and distributed independently, so they cannot share code via imports and must maintain their own implementations of common utilities.

Applied to files:

  • workspaces/ballerina/ballerina-extension/package.json
📚 Learning: 2025-11-10T15:04:50.474Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:153-169
Timestamp: 2025-11-10T15:04:50.474Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate, independently deployable VSCode extensions in the wso2/vscode-extensions repository. Code duplication between these extensions is acceptable and often necessary to maintain their independence, rather than creating cross-extension dependencies.

Applied to files:

  • workspaces/ballerina/ballerina-extension/package.json
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/**/*.config.{js,ts} : Use minimatch-compatible glob patterns for file matching in build and test configuration files

Applied to files:

  • workspaces/ballerina/ballerina-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Define all constants (node types, sizing, spacing) in src/resources/constants.ts and import them where needed instead of hardcoding values

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
📚 Learning: 2025-11-05T10:31:47.583Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 830
File: workspaces/ballerina/ballerina-extension/test/ai/post_proccess/post.test.ts:0-0
Timestamp: 2025-11-05T10:31:47.583Z
Learning: In the workspaces/ballerina/ballerina-extension project, the tsconfig.json uses "rootDirs": ["src", "test"], which allows test files to import from src using shorter relative paths. For example, from test/ai/post_proccess/, the import '../../stateMachine' correctly resolves to src/stateMachine.ts due to this configuration.

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
🧬 Code graph analysis (1)
workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts (1)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (1)
  • PackageTomlValues (109-111)
🔇 Additional comments (3)
workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts (1)

20-20: LGTM! Migration to @iarna/toml is correct.

The import and usage changes are appropriate for the @iarna/toml library. The parse function is correctly imported as a named export and used in place of toml.parse().

Also applies to: 36-36

workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts (1)

119-121: Return type has not been changed to Partial.

The current code at line 119-121 shows Promise<PackageTomlValues>, not Promise<Partial<PackageTomlValues>>. All five call sites (ConfigureRecordPage.tsx lines 113, 162; Configurables.tsx line 96; RecordConfigModal.tsx lines 240, 310) already use defensive access patterns with optional chaining and default values (tomValues?.package?.org || ""), so property access is safe regardless.

Likely an incorrect or invalid review comment.

workspaces/ballerina/ballerina-extension/package.json (1)

1232-1232: @iarna/toml ^2.2.5 is secure with no known vulnerabilities.

Version 2.2.5 is the latest in the 2.x series. Version 3.0.0 is available as a newer major release, but the caret constraint (^2.2.5) intentionally keeps the dependency within the 2.x range. No security advisories were found in the npm audit.


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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a333bcf and 3a9d55a.

⛔ Files ignored due to path filters (1)
  • common/config/rush/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • workspaces/ballerina/ballerina-extension/package.json (1 hunks)
  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts (2 hunks)
  • workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts (2 hunks)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts (3 hunks)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts (1 hunks)
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts (3 hunks)
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts (2 hunks)
  • workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts (1 hunks)
  • workspaces/bi/bi-extension/package.json (1 hunks)
  • workspaces/bi/bi-extension/src/utils.ts (3 hunks)
🧰 Additional context used
🧠 Learnings (8)
📓 Common learnings
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:224-242
Timestamp: 2025-11-10T15:05:11.309Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate VS Code extensions that are packaged and distributed independently, so they cannot share code via imports and must maintain their own implementations of common utilities.
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/**/*.config.{js,ts} : Use minimatch-compatible glob patterns for file matching in build and test configuration files

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
  • workspaces/ballerina/ballerina-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/bi/bi-extension/src/utils.ts
📚 Learning: 2025-11-05T10:31:47.583Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 830
File: workspaces/ballerina/ballerina-extension/test/ai/post_proccess/post.test.ts:0-0
Timestamp: 2025-11-05T10:31:47.583Z
Learning: In the workspaces/ballerina/ballerina-extension project, the tsconfig.json uses "rootDirs": ["src", "test"], which allows test files to import from src using shorter relative paths. For example, from test/ai/post_proccess/, the import '../../stateMachine' correctly resolves to src/stateMachine.ts due to this configuration.

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
  • workspaces/ballerina/ballerina-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/bi/bi-extension/src/utils.ts
📚 Learning: 2025-11-10T15:05:11.309Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:224-242
Timestamp: 2025-11-10T15:05:11.309Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate VS Code extensions that are packaged and distributed independently, so they cannot share code via imports and must maintain their own implementations of common utilities.

Applied to files:

  • workspaces/ballerina/ballerina-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/bi/bi-extension/src/utils.ts
📚 Learning: 2025-11-10T15:04:50.474Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:153-169
Timestamp: 2025-11-10T15:04:50.474Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate, independently deployable VSCode extensions in the wso2/vscode-extensions repository. Code duplication between these extensions is acceptable and often necessary to maintain their independence, rather than creating cross-extension dependencies.

Applied to files:

  • workspaces/ballerina/ballerina-extension/package.json
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/bi/bi-extension/src/utils.ts
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Define all constants (node types, sizing, spacing) in src/resources/constants.ts and import them where needed instead of hardcoding values

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Use TypeScript 5.8.3 with strict type checking enabled for all source files

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/bi/bi-extension/src/utils.ts
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/components/**/*.tsx : Use React 18.2.0 features including concurrent rendering and automatic batching; avoid class components in favor of functional components with hooks

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
🧬 Code graph analysis (5)
workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts (1)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (1)
  • PackageTomlValues (109-111)
workspaces/ballerina/ballerina-extension/src/utils/config.ts (2)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (2)
  • PackageTomlValues (109-111)
  • WorkspaceTomlValues (105-107)
workspaces/bi/bi-extension/src/utils.ts (1)
  • getWorkspaceTomlValues (179-190)
workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts (1)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (1)
  • PackageTomlValues (109-111)
workspaces/ballerina/ballerina-extension/src/utils/bi.ts (1)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (1)
  • WorkspaceTomlValues (105-107)
workspaces/bi/bi-extension/src/utils.ts (2)
workspaces/ballerina/ballerina-extension/src/utils/config.ts (2)
  • getProjectTomlValues (306-317)
  • getWorkspaceTomlValues (319-330)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (2)
  • PackageTomlValues (109-111)
  • WorkspaceTomlValues (105-107)
🔇 Additional comments (11)
workspaces/ballerina/ballerina-extension/package.json (2)

1231-1232: Update imports to use @iarna/toml library consistently across all modules.

The migration to @iarna/toml is incomplete. The following files still import from the old toml package and must be updated:

  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts
  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
  • workspaces/bi/bi-extension/src/utils.ts

Update these imports to @iarna/toml and adjust any parse/stringify calls to match the new API.

⛔ Skipped due to learnings
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/**/*.config.{js,ts} : Use minimatch-compatible glob patterns for file matching in build and test configuration files
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Define all constants (node types, sizing, spacing) in src/resources/constants.ts and import them where needed instead of hardcoding values
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:224-242
Timestamp: 2025-11-10T15:05:11.309Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate VS Code extensions that are packaged and distributed independently, so they cannot share code via imports and must maintain their own implementations of common utilities.
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 830
File: workspaces/ballerina/ballerina-extension/test/ai/post_proccess/post.test.ts:0-0
Timestamp: 2025-11-05T10:31:47.583Z
Learning: In the workspaces/ballerina/ballerina-extension project, the tsconfig.json uses "rootDirs": ["src", "test"], which allows test files to import from src using shorter relative paths. For example, from test/ai/post_proccess/, the import '../../stateMachine' correctly resolves to src/stateMachine.ts due to this configuration.
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Use TypeScript 5.8.3 with strict type checking enabled for all source files

1231-1232: The @iarna/[email protected] dependency is safe and verified.

The dependency migration from toml to @iarna/toml is syntactically correct. Version 2.2.5 exists on npm with no known security vulnerabilities or CVEs reported. The caret versioning (^2.2.5) is appropriate for this stable, actively maintained package.

workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts (1)

20-20: LGTM! Clean migration to @iarna/toml.

The import and usage have been correctly updated. The parsing logic remains functionally equivalent.

Also applies to: 36-36

workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts (1)

20-20: LGTM! Proper use of @iarna/toml stringify API.

The migration correctly uses stringify.value() to format TOML values instead of manual string construction. This ensures proper TOML escaping and formatting.

Also applies to: 148-149

workspaces/bi/bi-extension/src/utils.ts (1)

159-169: LGTM! Improved type safety with Partial types.

The return types now use Partial<>, which correctly reflects that parsed TOML may not contain all required fields. This is paired with defensive property access using optional chaining at call sites (lines 67, 143-144).

Note: getWorkspaceTomlValues is now exported, expanding the public API surface.

Also applies to: 179-189

workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts (1)

268-270: Public API signature updated to Partial type.

The return type now uses Partial<PackageTomlValues>, aligning with the updated getProjectTomlValues() implementation. This signature change propagates throughout the RPC layer and is consistent with the safer typing approach adopted across the codebase.

workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts (1)

68-68: LGTM! Defensive TOML parsing with optional chaining.

The migration properly uses Partial<PackageTomlValues> with optional chaining (tomlObj?.package?.name) to safely access potentially undefined properties. The error handling gracefully falls back to an empty string.

Also applies to: 816-820

workspaces/ballerina/ballerina-extension/src/utils/bi.ts (1)

41-41: LGTM! Consistent use of Partial types with safe defaults.

The migration correctly uses Partial<WorkspaceTomlValues> with nullish coalescing (?? []) to provide safe default values for potentially undefined properties. This pattern is applied consistently in both addToWorkspaceToml and deleteProjectFromWorkspace.

Also applies to: 366-367, 391-392

workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts (1)

119-121: Client-side signature updated to match server.

The return type now uses Partial<PackageTomlValues>, maintaining consistency with the corresponding server-side RPC manager method. This ensures type compatibility across the RPC boundary.

workspaces/ballerina/ballerina-extension/src/utils/config.ts (2)

24-24: LGTM! TOML parsing migration is correct.

The migration to @iarna/toml with Partial<> types is implemented consistently. The defensive typing is properly utilized at call sites (lines 214, 233, 265) with optional chaining.

Also applies to: 306-316, 319-329


343-346: Error handling needed for BI file creation.

The setupBIFiles call in fetchScope (when scope is determined) intentionally initializes the BI project structure by creating 8 essential Ballerina files (agents.bal, automation.bal, config.bal, connections.bal, data_mappings.bal, functions.bal, main.bal, types.bal). This behavior is guarded by two conditions: the project must be identified as a BI project, and a scope must exist.

However, setupBIFiles lacks error handling for fs.writeFileSync and could fail silently or throw unhandled errors in scenarios like read-only directories or permission issues. Consider wrapping the file creation in a try-catch block and logging any failures.

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: 1

🧹 Nitpick comments (3)
workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts (1)

34-41: Parse usage is correct.

The migration from toml.parse() to the named parse() function from @iarna/toml is implemented correctly, and the explicit return statement ensures a value is always returned.

Consider improving error handling to distinguish between parsing failures and valid empty configs. Currently, both cases return {}, which could lead to incorrect downstream behavior. For example:

-export function parseTomlToConfig(tomlContent: string): object {
+export function parseTomlToConfig(tomlContent: string): object | null {
     try {
         return parse(tomlContent);
     } catch (error) {
         debug("Error while parsing the Config.toml file content: " + error);
+        return null;  // Explicitly signal parsing failure
     }
-    return {};
 }

Then update callers to handle null appropriately. This would make parsing failures explicit rather than silently returning an empty object.

workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts (1)

44-45: TOML parsing switch in AI panel looks correct; consider reusing shared helper.

The updates to import PackageTomlValues, use parse from @iarna/toml, and cast to Partial<PackageTomlValues> with packageName = tomlObj?.package?.name align with the new TOML shape and guard against missing [package] or name fields. The error path falling back to '' for packageName is also safe for downstream usage.

As a follow-up (non-blocking), you could reuse getProjectTomlValues here instead of re-reading and parsing Ballerina.toml manually, to keep TOML parsing behavior centralized and consistent with other callers.

Also applies to: 68-69, 816-818

workspaces/ballerina/ballerina-extension/src/utils/config.ts (1)

24-25: @iarna/toml migration and Partial return types look consistent; callers must handle undefined.

The switch to parse from @iarna/toml and returning Partial<PackageTomlValues> | undefined / Partial<WorkspaceTomlValues> | undefined matches how these TOML files are used elsewhere and aligns with the bi-extension helpers. On failures (missing file or parse error), resolving to undefined is reasonable and is already handled in guard-style callers like checkIsBallerinaPackage, checkIsBallerinaWorkspace, and getBallerinaPackages.

Given this change, any remaining callers that still assume a non-undefined return type should be updated to handle the undefined case explicitly (or normalize to {} at their boundary, as done in RPC managers) to keep behavior predictable.

As an optional clean-up, you might later refactor places that manually regex-parse Ballerina.toml (e.g., getOrgPackageName) to reuse these helpers for a single TOML parsing path.

Also applies to: 306-316, 319-329

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3a9d55a and fc902e1.

⛔ Files ignored due to path filters (1)
  • common/config/rush/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (10)
  • workspaces/ballerina/ballerina-extension/package.json (1 hunks)
  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts (2 hunks)
  • workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts (2 hunks)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts (3 hunks)
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts (1 hunks)
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts (3 hunks)
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts (2 hunks)
  • workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts (1 hunks)
  • workspaces/bi/bi-extension/package.json (1 hunks)
  • workspaces/bi/bi-extension/src/utils.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • workspaces/ballerina/ballerina-extension/src/utils/bi.ts
  • workspaces/ballerina/ballerina-extension/src/features/tracing/utils.ts
  • workspaces/ballerina/ballerina-rpc-client/src/rpc-clients/common/rpc-client.ts
  • workspaces/bi/bi-extension/src/utils.ts
  • workspaces/bi/bi-extension/package.json
  • workspaces/ballerina/ballerina-extension/package.json
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/**/*.config.{js,ts} : Use minimatch-compatible glob patterns for file matching in build and test configuration files
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:224-242
Timestamp: 2025-11-10T15:05:11.309Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate VS Code extensions that are packaged and distributed independently, so they cannot share code via imports and must maintain their own implementations of common utilities.
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/**/*.config.{js,ts} : Use minimatch-compatible glob patterns for file matching in build and test configuration files

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Define all constants (node types, sizing, spacing) in src/resources/constants.ts and import them where needed instead of hardcoding values

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
📚 Learning: 2025-11-05T10:31:47.583Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 830
File: workspaces/ballerina/ballerina-extension/test/ai/post_proccess/post.test.ts:0-0
Timestamp: 2025-11-05T10:31:47.583Z
Learning: In the workspaces/ballerina/ballerina-extension project, the tsconfig.json uses "rootDirs": ["src", "test"], which allows test files to import from src using shorter relative paths. For example, from test/ai/post_proccess/, the import '../../stateMachine' correctly resolves to src/stateMachine.ts due to this configuration.

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts
  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
📚 Learning: 2025-11-10T15:05:11.309Z
Learnt from: madushajg
Repo: wso2/vscode-extensions PR: 868
File: workspaces/bi/bi-extension/src/utils.ts:224-242
Timestamp: 2025-11-10T15:05:11.309Z
Learning: The workspaces/bi/bi-extension and workspaces/ballerina/ballerina-extension are separate VS Code extensions that are packaged and distributed independently, so they cannot share code via imports and must maintain their own implementations of common utilities.

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/rpc-managers/ai-panel/rpc-manager.ts
📚 Learning: 2025-11-25T06:34:10.812Z
Learnt from: CR
Repo: wso2/vscode-extensions PR: 0
File: workspaces/ballerina/component-diagram/AGENTS.md:0-0
Timestamp: 2025-11-25T06:34:10.812Z
Learning: Applies to workspaces/ballerina/component-diagram/src/**/*.{ts,tsx} : Use TypeScript 5.8.3 with strict type checking enabled for all source files

Applied to files:

  • workspaces/ballerina/ballerina-extension/src/utils/config.ts
🧬 Code graph analysis (2)
workspaces/ballerina/ballerina-extension/src/rpc-managers/common/rpc-manager.ts (1)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (1)
  • PackageTomlValues (109-111)
workspaces/ballerina/ballerina-extension/src/utils/config.ts (2)
workspaces/ballerina/ballerina-core/src/rpc-types/common/interfaces.ts (2)
  • PackageTomlValues (109-111)
  • WorkspaceTomlValues (105-107)
workspaces/bi/bi-extension/src/utils.ts (1)
  • getWorkspaceTomlValues (179-190)
🔇 Additional comments (1)
workspaces/ballerina/ballerina-extension/src/features/config-generator/utils.ts (1)

20-20: The import statement has not been updated to use @iarna/toml.

The actual line 20 shows import toml from "toml";, which is still using the legacy package. The code snippet in the original comment does not match the actual state of the file. Additionally, @iarna/toml is not present in package.json, while the legacy toml package ("^3.0.0") remains as a dependency. Multiple other files also continue to import from the legacy toml package, indicating the migration is incomplete across the codebase.

Likely an incorrect or invalid review comment.

@madushajg madushajg merged commit 5609d4b into wso2:main Dec 2, 2025
6 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