Fission-AI/OpenSpec · error · TemplateLoadError

Template not found

Error message

Template not found: ${templatePathOnDisk}

What it means

TemplateLoadError raised when the resolved template path does not exist on disk after passing the path-containment check. Means the requested template file (relative path within the schema's templates directory, e.g. "proposal.md") is missing from an otherwise valid schema; the caller asked for a template the schema does not ship.

Solutions

  1. Add the missing template file to the schema's templates directory
  2. Correct the template filename in the schema's artifact definition
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/core/artifact-graph/instruction-loader.ts:233 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/c54e27ffebafc761. Report an issue: GitHub.

Appendix: source

Thrown at src/core/artifact-graph/instruction-loader.ts:233

      `Schema '${schemaName}' not found`,
      templatePath
    );
  }

  const templatesDir = path.join(schemaDir, 'templates');
  const templatePathOnDisk = path.join(templatesDir, templatePath);

  try {
    FileSystemUtils.assertPathWithin(templatesDir, templatePathOnDisk);
  } catch (error) {
    throw new TemplateLoadError(
      error instanceof Error ? error.message : String(error),
      templatePathOnDisk
    );
  }

  if (!fs.existsSync(templatePathOnDisk)) {
    throw new TemplateLoadError(
      `Template not found: ${templatePathOnDisk}`,
      templatePathOnDisk
    );
  }

  const fullPath = FileSystemUtils.canonicalizeExistingPath(templatePathOnDisk);

  try {
    return fs.readFileSync(fullPath, 'utf-8');
  } catch (err) {
    const ioError = err instanceof Error ? err : new Error(String(err));
    throw new TemplateLoadError(
      `Failed to read template: ${ioError.message}`,
      fullPath
    );
  }
}

View on GitHub (pinned to 6926ccb18a)