Fission-AI/OpenSpec · error

: target spec is structurally invalid and cannot be updated…

Error message

${specName}: target spec is structurally invalid and cannot be updated until fixed:
${details}

What it means

Thrown in buildUpdatedSpec when the existing target spec fails structural parsing (the details string enumerates what broke). Deltas can only be applied to a spec whose requirement blocks parse cleanly; a corrupt baseline must be repaired first.

Solutions

  1. Fix the structural problems listed in the error details in the target spec
  2. Run the spec validator to get fuller diagnostics on the broken file
  3. Restore the spec from version control if it was corrupted by an edit
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/core/specs-apply.ts:363 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/f692d21d7af3c9ae. Report an issue: GitHub.

Appendix: source

Thrown at src/core/specs-apply.ts:363

        `${specName} - delta Purpose ignored (it would leave the new spec unreadable); wrote the placeholder Purpose instead.`
      );
    } else if (overview && overview.length < MIN_PURPOSE_LENGTH) {
      // The placeholder always cleared this threshold, so a carried Purpose is
      // the first way archive can leave a spec that `validate --strict` fails.
      // Measured on the parsed overview, which is what the validator reads.
      warn(
        `${specName} - carried Purpose is under ${MIN_PURPOSE_LENGTH} characters; ` +
          `openspec validate --strict reports it as too brief.`
      );
    }
  }

  const structureIssues = findMainSpecStructureIssues(targetContent);
  if (structureIssues.length > 0) {
    const details = structureIssues
      .map(issue => `line ${issue.line}: ${issue.message}`)
      .join('\n');
    throw new Error(
      `${specName}: target spec is structurally invalid and cannot be updated until fixed:\n${details}`
    );
  }

  // Extract requirements section and build name->block map
  const parts = extractRequirementsSection(targetContent);
  const nameToBlock = new Map<string, RequirementBlock>();
  for (const block of parts.bodyBlocks) {
    nameToBlock.set(normalizeRequirementName(block.name), block);
  }

  // Apply operations in order: RENAMED → REMOVED → MODIFIED → ADDED
  // RENAMED
  let renamedApplied = 0;
  const renamedTargets = new Map<string, string>();
  for (const r of plan.renamed) {
    const from = normalizeRequirementName(r.from);
    const to = normalizeRequirementName(r.to);

View on GitHub (pinned to 6926ccb18a)