Fission-AI/OpenSpec · error

MODIFIED failed for header "### Requirement: " - not found

Error message

${specName} MODIFIED failed for header "### Requirement: ${mod.name}" - not found

What it means

Thrown in buildUpdatedSpec during MODIFIED application: the named requirement is not present in the baseline spec's parsed blocks. Unlike REMOVED, there is no early-sync leniency for MODIFIED — a modification always requires its target to exist.

Solutions

  1. Check the requirement header spelling in the change spec against the target spec
  2. Move the block to ADDED if the requirement is genuinely new
  3. Confirm the change targets the correct spec file
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

          );
        }
        warn(
          `${specName} - REMOVED requirement "${name}" is not in the current spec; treating it as already removed.`
        );
      }
      continue;
    }
    nameToBlock.delete(key);
    removedApplied++;
  }

  // MODIFIED
  let modifiedApplied = 0;
  for (const mod of plan.modified) {
    const key = normalizeRequirementName(mod.name);
    const currentBlock = nameToBlock.get(key);
    if (!currentBlock) {
      throw new Error(`${specName} MODIFIED failed for header "### Requirement: ${mod.name}" - not found`);
    }
    // Replace block with provided raw (ensure header line matches key)
    const modHeaderMatch = mod.raw.split('\n')[0].match(/^###\s*Requirement:\s*(.+)\s*$/i);
    if (!modHeaderMatch || normalizeRequirementName(modHeaderMatch[1]) !== key) {
      throw new Error(
        `${specName} MODIFIED failed for header "### Requirement: ${mod.name}" - header mismatch in content`
      );
    }
    const missingScenarios = findMissingCurrentScenarios(currentBlock, mod);
    if (missingScenarios.length > 0) {
      throw new Error(
        `${specName} MODIFIED failed for header "### Requirement: ${mod.name}" - current spec contains scenario(s) not present in the modified block: ${missingScenarios.map(name => `"${name}"`).join(', ')}. Refresh the change spec before archiving to avoid dropping scenarios.`
      );
    }
    // Identical content means the modification was already synced to the
    // baseline (early-sync pattern) — count only real replacements, so a
    // fully synced change still takes the "already in sync" write skip
    // instead of churning normalization differences into the file.

View on GitHub (pinned to 6926ccb18a)