{"record":{"id":"229c6f1cfda28ba9","repo":"Fission-AI/OpenSpec","slug":"context-output-dir-missing","errorCode":"context_output_dir_missing","errorMessage":"Output directory does not exist: ${parent}.","messagePattern":"Output directory does not exist: (.+?)\\.","errorType":"exception","errorClass":"StoreError","httpStatus":null,"severity":"error","filePath":"src/commands/context.ts","lineNumber":138,"sourceCode":"function writeCodeWorkspace(\n  workingSet: WorkingSet,\n  outputPath: string,\n  force: boolean\n): void {\n  const resolved = path.resolve(outputPath);\n  if (fs.existsSync(resolved) && !force) {\n    throw new StoreError(\n      `Refusing to overwrite ${resolved}.`,\n      'context_file_exists',\n      {\n        target: 'context.output',\n        fix: `Pass --force to overwrite, or choose a different path.`,\n      }\n    );\n  }\n  const parent = path.dirname(resolved);\n  if (!fs.existsSync(parent)) {\n    throw new StoreError(\n      `Output directory does not exist: ${parent}.`,\n      'context_output_dir_missing',\n      { target: 'context.output', fix: 'Create the directory first, or choose another path.' }\n    );\n  }\n\n  const rootName = workingSet.root.store_id ?? path.basename(workingSet.root.path);\n  fs.writeFileSync(resolved, buildCodeWorkspaceJson(workingSet, rootName));\n\n  const available = workingSet.members.filter(isAvailableMember).length;\n  const skipped = workingSet.members\n    .filter((member) => !isAvailableMember(member))\n    .map((member) => member.id);\n  const summary =\n    skipped.length > 0\n      ? `Wrote ${resolved} (${available + 1} folders; not available: ${skipped.join(', ')})`\n      : `Wrote ${resolved} (${available + 1} folders)`;\n  // stderr keeps JSON stdout pure; for humans it reads inline.","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/commands/context.ts#L120-L156","documentation":"Guard in writeCodeWorkspace: the parent directory of the resolved output path does not exist, so the workspace file cannot be written. Fires when the user passes an output path whose directory was never created; the fix is to create the directory (or pick an existing path).","triggerScenarios":"Thrown at src/commands/context.ts:138 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the output directory first (mkdir -p)","Point --output at an existing directory"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","contentChangedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}