{"record":{"id":"e633124a79544d8f","repo":"Fission-AI/OpenSpec","slug":"spec-must-have-a-purpose-section","errorCode":null,"errorMessage":"Spec must have a Purpose section","messagePattern":"Spec must have a Purpose section","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/core/parsers/markdown-parser.ts","lineNumber":35,"sourceCode":"    const normalized = MarkdownParser.normalizeContent(content);\n    this.lines = normalized.split('\\n');\n    this.codeFenceLineMask = buildCodeFenceMask(this.lines);\n    this.currentLine = 0;\n  }\n\n  protected static normalizeContent(content: string): string {\n    // Strip a UTF-8 BOM so a header on the first line still matches.\n    return content.replace(/^﻿/, '').replace(/\\r\\n?/g, '\\n');\n  }\n\n  parseSpec(name: string): Spec {\n    const sections = this.parseSections();\n    const purpose = this.findSection(sections, 'Purpose')?.content || '';\n    \n    const requirementsSection = this.findSection(sections, 'Requirements');\n    \n    if (!purpose) {\n      throw new Error('Spec must have a Purpose section');\n    }\n    \n    if (!requirementsSection) {\n      throw new Error('Spec must have a Requirements section');\n    }\n\n    const requirements = this.parseRequirements(requirementsSection);\n\n    return {\n      name,\n      overview: purpose.trim(),\n      requirements,\n      metadata: {\n        version: '1.0.0',\n        format: 'openspec',\n      },\n    };\n  }","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/parsers/markdown-parser.ts#L17-L53","documentation":"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.","triggerScenarios":"Thrown at src/core/parsers/markdown-parser.ts:35 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add a '## Purpose' section describing the spec's intent","Check heading spelling and level (##)","Ensure the section body is non-empty"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","contentChangedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}