{"record":{"id":"e67649709e3aaddc","repo":"google-gemini/gemini-cli","slug":"the-path-trimmedpath-does-not-exist","errorCode":null,"errorMessage":"The path \"${trimmedPath}\" does not exist.","messagePattern":"The path \"(.+?)\" does not exist\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/a2a-server/src/utils/path_utils.ts","lineNumber":58,"sourceCode":"    // Check if the resolved path is within the allowed root directory\n    if (\n      canonicalWorkspacePath !== canonicalAllowedRoot &&\n      !isSubpath(canonicalAllowedRoot, canonicalWorkspacePath)\n    ) {\n      throw new Error(\n        `Security violation: The path \"${trimmedPath}\" is outside the allowed root directory.`,\n      );\n    }\n\n    const stats = await fs.promises.stat(canonicalWorkspacePath);\n    if (!stats.isDirectory()) {\n      throw new Error(`The path \"${trimmedPath}\" is not a directory.`);\n    }\n\n    return canonicalWorkspacePath;\n  } catch (e) {\n    if (e instanceof Error && 'code' in e && e.code === 'ENOENT') {\n      throw new Error(`The path \"${trimmedPath}\" does not exist.`);\n    }\n    throw e; // Re-throw other errors\n  }\n}\n","sourceCodeStart":40,"sourceCodeEnd":63,"githubUrl":"https://github.com/google-gemini/gemini-cli/blob/5024443c7217464a66e98f80d73172a26440bd8f/packages/a2a-server/src/utils/path_utils.ts#L40-L63","documentation":"When fs.stat() throws an ENOENT error inside validateWorkspacePath(), the catch block intercepts it and re-throws with this user-friendly message. The path passed the null-byte and containment checks but does not exist on disk.","triggerScenarios":"Calling validateWorkspacePath() with a well-formed path within the allowed root that simply doesn't exist on the filesystem — e.g., a directory that hasn't been created yet or was deleted.","commonSituations":"Typo in path; directory not yet created; wrong working directory; race condition where the directory was removed between the containment check and the stat call.","solutions":["Create the directory (fs.mkdir or fse.ensureDir) before calling validateWorkspacePath.","Verify the path spelling and ensure it matches the actual filesystem layout.","Ensure the process CWD matches expectations when using relative allowedRoot defaults."],"exampleFix":"// before\nconst dir = await validateWorkspacePath('./myworkspace'); // throws if not on disk\n\n// after\nimport { ensureDir } from 'fs-extra';\nawait ensureDir('./myworkspace');\nconst dir = await validateWorkspacePath('./myworkspace');","handlingStrategy":"try-catch","validationCode":"import fse from 'fs-extra';\n\nasync function ensureWorkspaceExists(path: string): Promise<void> {\n  await fse.ensureDir(path);\n}\n\n// Before validation:\nawait ensureWorkspaceExists(workspacePath);\nconst safe = await validateWorkspacePath(workspacePath);","typeGuard":null,"tryCatchPattern":"try {\n  const dir = await validateWorkspacePath(candidate);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('does not exist')) {\n    await fse.ensureDir(candidate);\n    // retry or handle\n  } else {\n    throw e;\n  }\n}","preventionTips":["Create workspace directories with fse.ensureDir before validation.","Verify path spelling against the actual filesystem layout.","Avoid TOCTOU races by not deleting directories between validation and use."],"tags":["validation","filesystem","workspace","enoent"],"backgroundTag":null,"analyzedSha":"5024443c7217464a66e98f80d73172a26440bd8f","analyzedAt":"2026-08-12T06:01:53.711Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}