Fission-AI/OpenSpec · error · Error

Cannot fork schema with linked or unsupported entry

Error message

Cannot fork schema with linked or unsupported entry: ${sourcePath}: ${detail}

What it means

resolveSchemaCopyPath failed to canonicalize the schema source entry via realpathSync or the canonical path escaped the allowed root; the fork cannot copy entries it cannot confine (broken links, unsupported node types, escaping links).

Solutions

  1. Inspect the schema directory for broken or escaping symlinks and replace them with real files
  2. Copy the schema manually to the destination, excluding the problematic entry
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/commands/schema.ts:256 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Fission-AI/OpenSpec@6926ccb18a (2026-08-25). Data as JSON: /api/errors/1281484b68c86c21. Report an issue: GitHub.

Appendix: source

Thrown at src/commands/schema.ts:256

/**
 * Validate schema name format (kebab-case).
 */
function isValidSchemaName(name: string): boolean {
  return /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(name);
}

/**
 * Copy a directory recursively.
 */
function resolveSchemaCopyPath(allowedRoot: string, sourcePath: string): string {
  try {
    const canonicalRoot = fs.realpathSync(allowedRoot);
    const canonicalPath = fs.realpathSync(sourcePath);
    FileSystemUtils.assertPathWithin(canonicalRoot, canonicalPath);
    return canonicalPath;
  } catch (error) {
    const detail = error instanceof Error ? error.message : String(error);
    throw new Error(
      `Cannot fork schema with linked or unsupported entry: ${sourcePath}: ${detail}`,
      { cause: error }
    );
  }
}

function copyDirRecursive(
  src: string,
  dest: string,
  allowedRoot = src,
  ancestors = new Set<string>()
): void {
  const canonicalSrc = resolveSchemaCopyPath(allowedRoot, src);
  if (ancestors.has(canonicalSrc)) {
    throw new Error(`Cannot fork schema with a linked directory cycle: ${src}`);
  }
  ancestors.add(canonicalSrc);
  fs.mkdirSync(dest, { recursive: true });

View on GitHub (pinned to 6926ccb18a)