Fission-AI/OpenSpec · error · Error

Spec must have a Purpose section

Error message

Spec must have a Purpose section

What it means

Markdown structure guard in parseSpec: the spec document has no '## Purpose' section (or it is empty). Purpose is mandatory, so parsing aborts before requirements are read. Note the parser already strips BOM and normalizes line endings, so the section is genuinely absent.

Solutions

  1. Add a '## Purpose' section describing the spec's intent
  2. Check heading spelling and level (##)
  3. Ensure the section body is non-empty
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/core/parsers/markdown-parser.ts:35 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/e633124a79544d8f. Report an issue: GitHub.

Appendix: source

Thrown at src/core/parsers/markdown-parser.ts:35

    const normalized = MarkdownParser.normalizeContent(content);
    this.lines = normalized.split('\n');
    this.codeFenceLineMask = buildCodeFenceMask(this.lines);
    this.currentLine = 0;
  }

  protected static normalizeContent(content: string): string {
    // Strip a UTF-8 BOM so a header on the first line still matches.
    return content.replace(/^/, '').replace(/\r\n?/g, '\n');
  }

  parseSpec(name: string): Spec {
    const sections = this.parseSections();
    const purpose = this.findSection(sections, 'Purpose')?.content || '';
    
    const requirementsSection = this.findSection(sections, 'Requirements');
    
    if (!purpose) {
      throw new Error('Spec must have a Purpose section');
    }
    
    if (!requirementsSection) {
      throw new Error('Spec must have a Requirements section');
    }

    const requirements = this.parseRequirements(requirementsSection);

    return {
      name,
      overview: purpose.trim(),
      requirements,
      metadata: {
        version: '1.0.0',
        format: 'openspec',
      },
    };
  }

View on GitHub (pinned to 6926ccb18a)