{"record":{"id":"2bc1b6e8abb6e33c","repo":"coleam00/Archon","slug":"eexist","errorCode":"EEXIST","errorMessage":"Dry-run stub scaffold already exists: ${path}","messagePattern":"Dry-run stub scaffold already exists: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/workflows/src/dry-run.ts","lineNumber":277,"sourceCode":"    })\n  );\n}\n\n/** Write a scaffold without ever overwriting an existing fixture. */\nexport async function writeDryRunStubScaffold(\n  workflow: WorkflowDefinition,\n  path: string\n): Promise<DryRunStubs> {\n  const stubs = createDryRunStubScaffold(workflow);\n  await mkdir(dirname(path), { recursive: true });\n  let handle;\n  try {\n    handle = await open(path, 'wx');\n    await handle.writeFile(Bun.YAML.stringify(stubs));\n  } catch (error) {\n    const err = error as NodeJS.ErrnoException;\n    if (err.code === 'EEXIST') {\n      throw new Error(`Dry-run stub scaffold already exists: ${path}`);\n    }\n    throw error;\n  } finally {\n    await handle?.close();\n  }\n  return stubs;\n}\n\nconst dryRunNodeTypeSchema = z.enum([\n  'command',\n  'prompt',\n  'bash',\n  'script',\n  'loop',\n  'loop_group',\n  'approval',\n  'wait',\n  'cancel',","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/workflows/src/dry-run.ts#L259-L295","documentation":"Thrown by writeDryRunStubScaffold when opening the scaffold file with the exclusive 'wx' flag fails with EEXIST, meaning a file already exists at the target path. The scaffolder never overwrites an existing stub scaffold, so it raises a descriptive error instead of the raw EEXIST.","triggerScenarios":"Calling writeDryRunStubScaffold (via scaffold/written entry points) with a `path` where a stub file was already written by a previous dry-run scaffold invocation.","commonSituations":"Re-running scaffold generation without deleting the previous stub file, scripting that reuses the same output path, or a crashed earlier run that left the scaffold behind.","solutions":["Delete the existing scaffold file at `path` (or point to a new path) and re-run.","Edit the existing stub file in place instead of regenerating it.","In scripts, remove the stale file first (rm the recorded path) before scaffolding."],"exampleFix":"// before\nawait writeDryRunStubScaffold(dag, \"stubs.yaml\"); // EEXIST on second run\n// after\nawait fs.rm(\"stubs.yaml\", { force: true });\nawait writeDryRunStubScaffold(dag, \"stubs.yaml\");","handlingStrategy":"try-catch","validationCode":"import { existsSync } from \"node:fs\";\nfunction scaffoldPathIsFree(path: string): boolean {\n  return !existsSync(path);\n}","typeGuard":"null","tryCatchPattern":"try {\n  await writeDryRunStubScaffold(dag, path);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"Dry-run stub scaffold already exists\")) {\n    console.warn(`Reusing existing scaffold at ${path}`);\n    return await loadDryRunStubs(path);\n  }\n  throw err;\n}","preventionTips":["Delete or version the scaffold path before regenerating (timestamped filenames help).","Load the existing scaffold and edit it instead of re-scaffolding.","Clean up scaffold files in script teardown.","Use per-run output directories so reruns never collide."],"tags":["dry-run","filesystem","file-exists","stub"],"backgroundTag":"file-already-exists","analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}