Skip to content

Conversation

@ChinthakaJ98
Copy link
Contributor

@ChinthakaJ98 ChinthakaJ98 commented Nov 14, 2025

$subject

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling for file formatting operations to ensure the system gracefully handles formatting failures without losing or corrupting content.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

Added defensive error handling around the VS Code formatting command in the formatDMC function. The formatting operation is now wrapped in a try-catch block that logs errors and returns early if formatting fails, preserving existing behavior on success.

Changes

Cohort / File(s) Summary
RPC Manager Error Handling
workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts
Added try-catch wrapper around vscode.executeFormatDocumentProvider call in formatDMC function; logs error message and returns early on failure instead of propagating exceptions

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant formatDMC
    participant VS Code
    
    rect rgb(220, 240, 255)
    note over Client,VS Code: Before (No Error Handling)
    Client->>formatDMC: formatDMC()
    formatDMC->>VS Code: executeFormatDocumentProvider()
    alt Success
        VS Code-->>formatDMC: TextEdit[]
        formatDMC->>Client: Apply edits
    else Exception
        VS Code-->>formatDMC: Error
        formatDMC-->>Client: ✗ Exception propagates
    end
    end
    
    rect rgb(240, 255, 240)
    note over Client,VS Code: After (With Error Handling)
    Client->>formatDMC: formatDMC()
    formatDMC->>VS Code: executeFormatDocumentProvider()
    alt Success
        VS Code-->>formatDMC: TextEdit[]
        formatDMC->>Client: Apply edits
    else Exception
        VS Code-->>formatDMC: Error
        formatDMC->>formatDMC: Log error message
        formatDMC->>Client: Return early (silent)
    end
    end
Loading

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single file modification with localized error handling
  • Straightforward try-catch pattern with no complex logic
  • Review focuses on confirming appropriate error logging and early return behavior

Suggested reviewers

  • hevayo
  • gigara

Poem

🐰 A catch for the format, a shield from the fall,
When VS Code stumbles, we've handled it all.
With logs and with grace, errors now rest,
The DMC mapper passes its safety test!

Pre-merge checks and finishing touches

❌ Failed checks (3 warnings)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Fix E2E tests' is vague and generic. While it mentions E2E tests, the actual change involves adding error handling to the formatDMC function in the RPC manager, which is unrelated to test fixes. Revise the title to accurately reflect the code change, such as 'Add error handling to formatDMC function in RPC manager' or similar.
Description check ⚠️ Warning The PR description is empty, containing only a placeholder variable '$subject' with no actual description of the changes, purpose, or approach. Provide a complete PR description following the repository template, including Purpose, Goals, Approach, and relevant sections to explain the error handling changes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✨ 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 0193590 and 0359e39.

📒 Files selected for processing (1)
  • workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts

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

🧹 Nitpick comments (1)
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.ts (1)

105-276: Consider documenting the retention of this unused function.

Since the test registration on line 43 is commented out, this function is currently unused. If this is a temporary measure and the test will be re-enabled soon, consider adding a comment at the function definition explaining this. Otherwise, you might want to temporarily remove the function to reduce code clutter until it's ready to be used again.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 20f6525 and e41d094.

📒 Files selected for processing (1)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.ts (1 hunks)

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

🧹 Nitpick comments (1)
workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/DataMapper.ts (1)

298-298: Consider waiting for a specific condition instead of a fixed delay.

Fixed delays like waitForTimeout(2000) are generally discouraged in E2E tests because they:

  • Add unnecessary wait time when the condition is satisfied earlier
  • May still be flaky if 2000ms isn't always sufficient
  • Don't clearly communicate what condition is being awaited

Investigate whether there's a specific condition you can wait for after filling the textarea. For example:

 const textArea = this.sidePanel.locator(`textarea`);
 await textArea.waitFor();
 await textArea.fill(content);

-await page.page.waitForTimeout(2000);
-
 const submitBtn = this.sidePanel.locator(`vscode-button:text("Save")`);
 await submitBtn.waitFor();
+await expect(submitBtn).toBeEnabled();
 await submitBtn.click();

Or if there's a loading indicator, validation message, or network request you can wait for:

// Wait for validation/processing to complete
await this.sidePanel.locator('.validation-complete').waitFor();
// or
await this.container.waitForLoadState('networkidle');

Can you verify what specific condition needs to be satisfied before clicking Save? This would make the test more reliable and potentially faster.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e41d094 and 52f8001.

📒 Files selected for processing (2)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/DataMapper.ts (1 hunks)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.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.

Actionable comments posted: 0

🧹 Nitpick comments (2)
workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (2)

149-157: Consider removing debug logs or using a proper logging framework.

The console.error calls on lines 150 and 153 appear to be debug logging rather than actual error logging. While helpful for troubleshooting E2E tests, these should be removed before merging or replaced with a proper logging framework to avoid cluttering production console output.


158-162: Consider removing debug logs or using a proper logging framework.

Similar to the previous segment, the console.error statements on lines 158, 160, and 162 are debug logs tracking the execution flow. These should be cleaned up or moved to a proper logging framework before production deployment.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 52f8001 and 5fba2fb.

📒 Files selected for processing (4)
  • workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (1 hunks)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/DataMapper.ts (1 hunks)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.ts (1 hunks)
  • workspaces/mi/mi-extension/src/util/tsBuilder.ts (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • workspaces/mi/mi-extension/src/util/tsBuilder.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.ts
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/DataMapper.ts
🧰 Additional context used
🧬 Code graph analysis (1)
workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (2)
workspaces/mi/mi-extension/src/util/tsBuilder.ts (2)
  • updateTsFileIoTypes (35-114)
  • updateTsFileCustomTypes (116-153)
workspaces/mi/mi-extension/src/stateMachine.ts (1)
  • refreshUI (797-811)
🔇 Additional comments (1)
workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (1)

164-168: Good error handling improvement.

The enhanced error handling properly logs the error, displays a user-friendly message, and returns a failure response. This is a solid improvement to the error flow.

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/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (1)

164-168: Consider providing more specific error details to users.

The error handling correctly logs and returns { success: false }, but the user-facing error message is generic. While console.error(error) helps developers debug, users only see "Error while updating DMC file." without understanding what went wrong.

Consider including error context in the user message (while being careful not to expose sensitive information):

  } catch (error: any) {
      console.error(error);
-     window.showErrorMessage("Error while updating DMC file.");
+     window.showErrorMessage(`Error while updating DMC file: ${error?.message || 'Unknown error'}`);
      return resolve({ success: false });
  }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5fba2fb and 648d830.

📒 Files selected for processing (4)
  • workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (1 hunks)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/DataMapper.ts (1 hunks)
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.ts (1 hunks)
  • workspaces/mi/mi-extension/src/util/tsBuilder.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • workspaces/mi/mi-extension/src/util/tsBuilder.ts
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/components/DataMapper.ts
  • workspaces/mi/mi-extension/src/test/e2e-playwright-tests/dataMapper.spec.ts
🧰 Additional context used
🧬 Code graph analysis (1)
workspaces/mi/mi-extension/src/rpc-managers/mi-data-mapper/rpc-manager.ts (2)
workspaces/mi/mi-extension/src/util/tsBuilder.ts (2)
  • updateTsFileIoTypes (35-114)
  • updateTsFileCustomTypes (116-153)
workspaces/mi/mi-extension/src/stateMachine.ts (1)
  • refreshUI (797-811)

@gigara gigara merged commit e97ea2b into wso2:main Nov 15, 2025
11 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants