{"record":{"id":"41b600a2540de531","repo":"angular/angular-cli","slug":"failed-to-verify-workspace-path-workspacepath","errorCode":null,"errorMessage":"Failed to verify workspace path '${workspacePath}': ${e instanceof Error ? e.message : e}. Falling back to the bundled guide.","messagePattern":"Failed to verify workspace path '(.+?)': (.+?)\\. Falling back to the bundled guide\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/angular/cli/src/commands/mcp/tools/best-practices.ts","lineNumber":104,"sourceCode":" * ```\n *\n * @param workspacePath The absolute path to the user's `angular.json` file.\n * @param logger The MCP tool context logger for reporting warnings.\n * @param server The MCP server context, used to enforce the client's declared roots.\n * @returns A promise that resolves to an object containing the guide's content and source,\n *     or `undefined` if the guide could not be resolved.\n */\nasync function getVersionSpecificBestPractices(\n  workspacePath: string,\n  logger: McpToolContext['logger'],\n  server: McpToolContext['server'],\n): Promise<{ content: string; source: string } | undefined> {\n  if (server) {\n    let isAllowed: boolean;\n    try {\n      isAllowed = await isAllowedWorkspacePath(server, workspacePath);\n    } catch (e) {\n      logger.warn(\n        `Failed to verify workspace path '${workspacePath}': ` +\n          `${e instanceof Error ? e.message : e}. Falling back to the bundled guide.`,\n      );\n\n      return undefined;\n    }\n\n    if (!isAllowed) {\n      throw new Error(\n        `Workspace path is outside the allowed MCP roots: ${workspacePath}. ` +\n          \"You can use 'list_projects' to find available workspaces.\",\n      );\n    }\n  }\n\n  // 1. Resolve the path to package.json\n  let pkgJsonPath: string;\n  try {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/angular/cli/src/commands/mcp/tools/best-practices.ts#L86-L122","documentation":"getVersionSpecificBestPractices verifies that the requested workspace path is allowed (via isAllowedWorkspacePath against the MCP server roots) before reading version-specific Angular best-practices docs. If the verification throws, the tool warns and returns undefined so the caller falls back to the bundled guide.","triggerScenarios":"The MCP client requests version-specific best practices for a workspacePath while isAllowedWorkspacePath throws — e.g. the server connection is broken, roots are unavailable, or path checks fail unexpectedly.","commonSituations":"MCP roots not initialized (see roots-init warning); client requesting paths outside allowed roots; transient server/client communication errors during tool calls.","solutions":["Ensure the requested workspacePath is within the MCP server's configured roots.","Verify MCP roots were initialized successfully on connection (watch for the roots warnings).","Retry the tool call; the bundled best-practices guide is used as fallback meanwhile."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Pre-check the path is under an allowed root before calling the tool:\nconst allowed = roots.some((root) => resolve(workspacePath).startsWith(resolve(root) + path.sep));\nif (!allowed) console.warn('workspacePath is outside MCP roots; bundled guide will be used.');","typeGuard":null,"tryCatchPattern":"try {\n  const guide = await getVersionSpecificBestPractices(server, workspacePath, logger, version);\n} catch {\n  const guide = getBundledBestPractices(); // fallback\n}","preventionTips":["Request best practices only for paths inside the MCP server's roots.","Ensure roots initialized successfully before calling tools.","Accept the bundled-guide fallback as the designed safety net."],"tags":["mcp","workspace-path","best-practices","security"],"backgroundTag":"workspace-path-verification-failed","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}