fix: guard against undefined extension.exports in MCP server init#1929
fix: guard against undefined extension.exports in MCP server init#1929dev-punia-altimate wants to merge 1 commit into
Conversation
…-autopilot) Add null check for extension.exports before accessing .ready property in updateMcpExtensionApi(). When the Altimate MCP Server extension is present but hasn't fully initialized its exports, the previous code threw 'Cannot read properties of undefined (reading ready)' — seen 2270 times in telemetry in 24h across versions 0.51.2–0.60.7.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
|
❌ Critic Review — BLOCK ❌ BLOCK — CI checks still pending Rule-CI-PENDING: 7 required checks are still running. Cannot merge or approve until CI completes.
5 checks already passed: Analyze (actions), Analyze (python), CodeQL, GitGuardian Security Checks, security/snyk — no issues there. Preliminary code-quality assessment (not blocking on its own): The fix and tests look high quality:
If CI passes, this PR is ready to PROCEED. Re-run critic after CI completes. Agent blocks are reversible via Quality Critic • View run |
|
🔴 Critic Finding [CRITICAL] — Rule-CI-PENDING 7 required checks are still in progress: build (macos-latest, darwin-arm64), build (ubuntu-latest, linux-x64), build (windows-latest, win32-x64), test (macos-latest), test (ubuntu-latest), test (windows-latest), Analyze (javascript-typescript). Re-run critic after all CI checks complete.
Quality Critic • View run |
Bundle Size Reportdarwin-arm64: 74.2 MB
linux-x64: 75.9 MB
win32-x64: 76.8 MB
|
ralphstodomingo
left a comment
There was a problem hiding this comment.
being addressed in #1926
Evidence Matrix
DbtPowerUserMcpServer:updateMcpExtensionApiError, message: "Cannot read properties of undefined (reading 'ready')"src/mcp/index.ts:55—extension.exports.readyaccessed without null checkDbtPowerUserMcpServer.updateMcpExtensionApi()— created new test suiteDiscovery
Azure Application Insights telemetry shows 2270 occurrences of
Cannot read properties of undefined (reading 'ready')in the last 24 hours across versions 0.51.2–0.60.7 and all modes (core, cloud, fusion). Top event:DbtPowerUserMcpServer:updateMcpExtensionApiError.Root Cause Analysis
In
src/mcp/index.ts, theupdateMcpExtensionApi()method:altimateai.vscode-altimate-mcp-serverextension viaextensions.getExtension()extension.exports.readywithout checking ifexportsis defined ❌VS Code's
Extension.exportsis typed asT | undefined. When the MCP extension is present but hasn't fully initialized its exports (e.g., during a race condition at activation),exportsisundefined, and accessing.readythrows the TypeError.The error is caught by the surrounding try/catch, so it doesn't crash the extension — but it generates 2270 telemetry noise events per day and prevents MCP tool registration.
Why This Fix Resolves It
Added an explicit
!extension.exportsguard (line 55–62) that:!extensionat line 43dbtTerminal.errorfor debuggabilitymcpExtensionApistaysundefined, which is already handled by the null check inregisterToolsInMcpExtension()at line 87Self-Critique
.readyon undefined, andextension.exportsis the only object before.readythat can be undefinedexportsbeing undefined (MCP extension activation timing) is not fixed — this is a defensive guard. If the MCP extension consistently fails to export, tools won't register.updateMcpExtensionApi()Impact
Generated by QA Autopilot | Extension Telemetry