Fission-AI/OpenSpec · error · Error
Requirement not found
Error message
Requirement ${requirementOpt} not found What it means
Thrown by validateRequirementIndex when the --requirement option is a number outside the range of requirements parsed from the spec (or not a valid index). Means the requested requirement does not exist in that spec, not a parsing failure.
Solutions
- Check the spec's requirement names and pass an exact match
- Omit --requirement to show all requirements
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/commands/spec.ts:56 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/b202f4302faead8a.
Report an issue: GitHub.
Appendix: source
Thrown at src/commands/spec.ts:56
requirements?: boolean;
scenarios?: boolean; // --no-scenarios sets this to false (JSON only)
requirement?: string; // JSON only
noInteractive?: boolean;
rootOutput?: RootOutput;
}
function parseSpecFromFile(specsDir: string, specPath: string, specId: string): Spec {
assertSpecPath(specsDir, specPath);
const content = readFileSync(specPath, 'utf-8');
const parser = new MarkdownParser(content);
return parser.parseSpec(specId);
}
function validateRequirementIndex(spec: Spec, requirementOpt?: string): number | undefined {
if (!requirementOpt) return undefined;
const index = Number.parseInt(requirementOpt, 10);
if (!Number.isInteger(index) || index < 1 || index > spec.requirements.length) {
throw new Error(`Requirement ${requirementOpt} not found`);
}
return index - 1; // convert to 0-based
}
function filterSpec(spec: Spec, options: ShowOptions): Spec {
const requirementIndex = validateRequirementIndex(spec, options.requirement);
const includeScenarios = options.scenarios !== false && !options.requirements;
const filteredRequirements = (requirementIndex !== undefined
? [spec.requirements[requirementIndex]]
: spec.requirements
).map(req => ({
text: req.text,
scenarios: includeScenarios ? req.scenarios : [],
}));
const metadata = spec.metadata ?? { version: '1.0.0', format: 'openspec' as const };
View on GitHub (pinned to 6926ccb18a)