{"record":{"id":"f692d21d7af3c9ae","repo":"Fission-AI/OpenSpec","slug":"specname-target-spec-is-structurally-invalid-a","errorCode":null,"errorMessage":"${specName}: target spec is structurally invalid and cannot be updated until fixed:\n${details}","messagePattern":"(.+?): target spec is structurally invalid and cannot be updated until fixed:\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/core/specs-apply.ts","lineNumber":363,"sourceCode":"        `${specName} - delta Purpose ignored (it would leave the new spec unreadable); wrote the placeholder Purpose instead.`\n      );\n    } else if (overview && overview.length < MIN_PURPOSE_LENGTH) {\n      // The placeholder always cleared this threshold, so a carried Purpose is\n      // the first way archive can leave a spec that `validate --strict` fails.\n      // Measured on the parsed overview, which is what the validator reads.\n      warn(\n        `${specName} - carried Purpose is under ${MIN_PURPOSE_LENGTH} characters; ` +\n          `openspec validate --strict reports it as too brief.`\n      );\n    }\n  }\n\n  const structureIssues = findMainSpecStructureIssues(targetContent);\n  if (structureIssues.length > 0) {\n    const details = structureIssues\n      .map(issue => `line ${issue.line}: ${issue.message}`)\n      .join('\\n');\n    throw new Error(\n      `${specName}: target spec is structurally invalid and cannot be updated until fixed:\\n${details}`\n    );\n  }\n\n  // Extract requirements section and build name->block map\n  const parts = extractRequirementsSection(targetContent);\n  const nameToBlock = new Map<string, RequirementBlock>();\n  for (const block of parts.bodyBlocks) {\n    nameToBlock.set(normalizeRequirementName(block.name), block);\n  }\n\n  // Apply operations in order: RENAMED → REMOVED → MODIFIED → ADDED\n  // RENAMED\n  let renamedApplied = 0;\n  const renamedTargets = new Map<string, string>();\n  for (const r of plan.renamed) {\n    const from = normalizeRequirementName(r.from);\n    const to = normalizeRequirementName(r.to);","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/Fission-AI/OpenSpec/blob/6926ccb18afa4ff621112813e9968334576ee11a/src/core/specs-apply.ts#L345-L381","documentation":"Error \"${specName}: target spec is structurally invalid and cannot be updated until fixed:\n${details}\" thrown in Fission-AI/OpenSpec.","triggerScenarios":"Thrown at src/core/specs-apply.ts:363 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6926ccb18afa4ff621112813e9968334576ee11a","analyzedAt":"2026-08-25T12:29:45.729Z","schemaVersion":2},"datasetVersion":"2026-08-25T16:17:27.014Z"}