{"record":{"id":"360e9187f8c4aedc","repo":"facebook/flow","slug":"failed-to-find-extensionpath","errorCode":null,"errorMessage":"Failed to find extensionPath","messagePattern":"Failed to find extensionPath","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/flow-for-vscode/src/utils/getExtensionPath.ts","lineNumber":15,"sourceCode":"/**\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\nimport * as vscode from 'vscode';\n\nconst THIS_EXSTENSION_ID = 'flowtype.flow-for-vscode';\n\nexport default function getExtensionPath(): string {\n  const thisExtension = vscode.extensions.getExtension(THIS_EXSTENSION_ID);\n  if (!thisExtension) {\n    throw new Error('Failed to find extensionPath');\n  }\n  return thisExtension.extensionPath;\n}\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/facebook/flow/blob/d1341dac899a79c027762f6b423d896045287620/packages/flow-for-vscode/src/utils/getExtensionPath.ts#L1-L19","documentation":"getExtensionPath() asks the VS Code API for the extension with the fixed ID 'flowtype.flow-for-vscode' and returns its install path. When vscode.extensions.getExtension returns undefined — the extension is not installed or enabled in this host — it throws 'Failed to find extensionPath'.","triggerScenarios":"Calling the extension's utils outside a real extension host (unit tests, running from source), the extension being installed under a different publisher ID, or the host not having the extension activated/enabled.","commonSituations":"Unit tests importing flow-for-vscode utils without mocking the vscode module; forks published under another publisher ID; the extension disabled for the workspace.","solutions":["Mock `vscode.extensions.getExtension` in tests to return an object with extensionPath","Ensure the extension is installed and enabled under the exact ID 'flowtype.flow-for-vscode'","If you forked the extension, update THIS_EXSTENSION_ID in getExtensionPath.ts to your publisher ID"],"exampleFix":"// before (test)\nimport getExtensionPath from 'flow-for-vscode/src/utils/getExtensionPath';\ngetExtensionPath(); // throws: no real extension host\n\n// after (test)\nvi.mock('vscode', () => ({\n  extensions: {\n    getExtension: () => ({ extensionPath: '/fake/ext/path' }),\n  },\n}));","handlingStrategy":"type-guard","validationCode":"import * as vscode from 'vscode';\n\nfunction extensionPathAvailable(): boolean {\n  return vscode.extensions.getExtension('flowtype.flow-for-vscode') != null;\n}","typeGuard":"function getExtensionPathOrNull(): string | null {\n  const ext = vscode.extensions.getExtension('flowtype.flow-for-vscode');\n  return ext != null ? ext.extensionPath : null;\n}","tryCatchPattern":null,"preventionTips":["Only call extension utils inside the activation/extension-host context","Mock the vscode module in unit tests","Keep publisher IDs in sync when forking the extension"],"tags":["vscode","extension","testing","mock"],"backgroundTag":"vscode-extension-not-found","analyzedSha":"d1341dac899a79c027762f6b423d896045287620","analyzedAt":"2026-08-17T00:07:02.212Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}