{"record":{"id":"48614aef97aa615a","repo":"Fission-AI/OpenSpec","slug":"cannot-fork-schema-with-a-linked-directory-cycle","errorCode":null,"errorMessage":"Cannot fork schema with a linked directory cycle: ${src}","messagePattern":"Cannot fork schema with a linked directory cycle: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/commands/schema.ts","lineNumber":271,"sourceCode":"    return canonicalPath;\n  } catch (error) {\n    const detail = error instanceof Error ? error.message : String(error);\n    throw new Error(\n      `Cannot fork schema with linked or unsupported entry: ${sourcePath}: ${detail}`,\n      { cause: error }\n    );\n  }\n}\n\nfunction copyDirRecursive(\n  src: string,\n  dest: string,\n  allowedRoot = src,\n  ancestors = new Set<string>()\n): void {\n  const canonicalSrc = resolveSchemaCopyPath(allowedRoot, src);\n  if (ancestors.has(canonicalSrc)) {\n    throw new Error(`Cannot fork schema with a linked directory cycle: ${src}`);\n  }\n  ancestors.add(canonicalSrc);\n  fs.mkdirSync(dest, { recursive: true });\n\n  try {\n    const entries = fs.readdirSync(src, { withFileTypes: true });\n    for (const entry of entries) {\n      const srcPath = path.join(src, entry.name);\n      const destPath = path.join(dest, entry.name);\n      const canonicalEntry = resolveSchemaCopyPath(allowedRoot, srcPath);\n      const stats = fs.statSync(canonicalEntry);\n\n      if (stats.isDirectory()) {\n        copyDirRecursive(canonicalEntry, destPath, allowedRoot, ancestors);\n      } else if (stats.isFile()) {\n        // Dereference confined links so the fork is an independent schema.\n        fs.copyFileSync(canonicalEntry, destPath);\n      } else {","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/commands/schema.ts#L253-L289","documentation":"Error \"Cannot fork schema with a linked directory cycle: ${src}\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/commands/schema.ts:271 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-08-25T16:17:27.014Z"}