Skip to content

Comments

Fix issues in the MI Extension#1504

Merged
ChinthakaJ98 merged 5 commits intowso2:mainfrom
ChinthakaJ98:mi-fixes-15
Feb 20, 2026
Merged

Fix issues in the MI Extension#1504
ChinthakaJ98 merged 5 commits intowso2:mainfrom
ChinthakaJ98:mi-fixes-15

Conversation

@ChinthakaJ98
Copy link
Contributor

@ChinthakaJ98 ChinthakaJ98 commented Feb 19, 2026

This PR will fix the below mentioned issues.

Summary by CodeRabbit

  • Bug Fixes

    • Environment variable parsing now correctly handles values containing '=' and other special characters.
    • Test server startup now loads environment variables from a .env file in the project root and runs in the project context.
    • Class name validation relaxed to allow lowercase starting letters.
  • Chores

    • Updated test plugin version used for unit-test execution.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 19, 2026

No actionable comments were generated in the recent review. 🎉


📝 Walkthrough

Walkthrough

Env parsing was changed to preserve '=' characters in values and only add non-empty key/value pairs; .env loading is integrated into test server startup by adding a projectRoot parameter; className validation was relaxed to allow lowercase starts; a plugin version constant was bumped.

Changes

Cohort / File(s) Summary
Env parsing (debugger)
workspaces/mi/mi-extension/src/debugger/activate.ts, workspaces/mi/mi-extension/src/debugger/tasks.ts
Parse env lines by splitting on the first '=' and joining the rest to preserve '=' characters in values; only non-empty keys/values are added.
Test server startup / runner
workspaces/mi/mi-extension/src/test-explorer/runner.ts
startTestServer signature adds projectRoot; it now calls loadEnvVariables(projectRoot/.env) before spawning the server and uses projectRoot as the command working directory. Also imports loadEnvVariables.
Form validation
workspaces/mi/mi-visualizer/src/views/Forms/ClassMediatorForm.tsx
Relaxed className validation to accept identifiers starting with either uppercase or lowercase letters.
Template constant bump
workspaces/mi/mi-extension/src/util/templates.ts
Updated LATEST_CAR_PLUGIN_VERSION from "5.4.13" to "5.4.15" (plugin version bump).

Sequence Diagram(s)

mermaid
sequenceDiagram
participant TE as Test Explorer / runner
participant Tasks as debugger/tasks (loadEnvVariables)
participant FS as Filesystem (.env)
participant CP as ChildProcess (test server)
TE->>Tasks: request loadEnvVariables(projectRoot/.env)
Tasks->>FS: read .env file
FS-->>Tasks: return lines
Tasks-->>TE: return env map
TE->>CP: spawn server (cwd=projectRoot, env=merged)
CP-->>TE: server started / output

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I nibble keys where equals hide,

I stitch the rest on the value's side.
I hop to the server, bring .env's light,
Lowercase names now leap in sight.
A tiny thump — the code feels right. 🥕

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal, providing only issue links without addressing most required template sections like Purpose, Goals, Approach, test coverage, security checks, or test environment details. Expand the description to include Purpose (problem statement), Goals (solutions), Approach (implementation details), Automation tests coverage, Security checks confirmation, and Test environment specifications.
Docstring Coverage ⚠️ Warning Docstring coverage is 42.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix issues in the MI Extension' is vague and generic, using non-descriptive language that doesn't convey specific information about which issues are being fixed or what the main technical changes entail. Provide a more specific title that describes the primary change, such as 'Fix environment variable parsing and update plugin version' or reference the main technical improvement.

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

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 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.

gigara
gigara previously approved these changes Feb 19, 2026
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-explorer/runner.ts (1)

275-277: throw error inside an async Promise executor leaves the outer Promise permanently pending.

In new Promise(async (resolve, reject) => { ... }), a throw inside the async executor rejects the executor's own implicit async promise — it is not caught by the Promise constructor. The outer Promise<{ cp: ChildProcess }> remains pending forever, causing await startTestServer(...) at line 103 to hang indefinitely rather than propagating the error to the runTestQueue catch block.

The new loadEnvVariables call adds a concrete new throw vector (e.g., fs.readFileSync failing despite existsSync passing), making this pre-existing antipattern more likely to trigger.

♻️ Proposed fix — call `reject` explicitly
         } catch (error) {
-            throw error;
+            reject(error);
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@workspaces/mi/mi-extension/src/test-explorer/runner.ts` around lines 275 -
277, The Promise executor in startTestServer (the new Promise(async (resolve,
reject) => { ... })) currently uses "throw error" inside the async executor
which leaves the outer Promise pending; change the executor to explicitly reject
on failures instead of throwing (or remove the async keyword and use synchronous
try/catch that calls reject(error)). Specifically, inside the Promise in
runner.ts where the catch currently does "throw error;", replace that with a
call to reject(error) (or ensure any thrown errors from loadEnvVariables and
related calls are caught and passed to reject) so the outer Promise<{ cp:
ChildProcess }> properly rejects and the await startTestServer(...) can handle
the error.
🤖 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/mi/mi-extension/src/debugger/tasks.ts`:
- Around line 195-198: The guard currently checks "if (key && value)" but value
is an array and always truthy; change the logic to produce a string value before
the guard (e.g., join value with '=' and trim into a variable like valueStr) and
then check "if (key && valueStr)" before assigning to process.env; update the
block that destructures trimmedLine (const [key, ...value]) to compute valueStr
= value.join('=').trim() and use that in the conditional and assignment to avoid
setting env vars for lines without '=' or empty values.

---

Nitpick comments:
In `@workspaces/mi/mi-extension/src/test-explorer/runner.ts`:
- Around line 275-277: The Promise executor in startTestServer (the new
Promise(async (resolve, reject) => { ... })) currently uses "throw error" inside
the async executor which leaves the outer Promise pending; change the executor
to explicitly reject on failures instead of throwing (or remove the async
keyword and use synchronous try/catch that calls reject(error)). Specifically,
inside the Promise in runner.ts where the catch currently does "throw error;",
replace that with a call to reject(error) (or ensure any thrown errors from
loadEnvVariables and related calls are caught and passed to reject) so the outer
Promise<{ cp: ChildProcess }> properly rejects and the await
startTestServer(...) can handle the error.

@ChinthakaJ98 ChinthakaJ98 merged commit 34a81fc into wso2:main Feb 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants