affaan-m/ECC · error

Missing merge payload for repair

Error message

Missing merge payload for repair: ${operation.destinationPath}

What it means

Thrown during repair when a 'merge-json' operation has no JSON payload (getOperationJsonPayload returns undefined). Repair needs the payload to re-merge into the existing destination file; a payload-less merge operation cannot be replayed.

Solutions

  1. Re-run install to regenerate a complete install-state record
  2. Verify each merge-json operation in the state has a defined payload before repairing
  3. Align versions of the installer that wrote the state and the code performing repair
  4. Discard the corrupt state record and reinstall cleanly

Example fix

// before
repairFromRecord(record); // record.operations[i].payload === undefined
// after
const ok = record.operations.every(op => op.kind !== 'merge-json' || op.payload !== undefined);
if (!ok) await reinstall(); else repairFromRecord(record);
Defensive patterns

Strategy: validation

Validate before calling

const bad = record.state.operations.find(op => op.kind === 'merge-json' && op.payload === undefined);
if (bad) throw new Error(`merge-json op for ${bad.destinationPath} lacks payload; reinstall`);

Type guard

function hasMergePayload(op) { return op.kind !== 'merge-json' || op.payload !== undefined; }

Try / catch

try { repairFromRecord(record); } catch (e) { if (String(e.message).startsWith('Missing merge payload for repair')) { await reinstallAndRepair(); } else throw e; }

Prevention

When it happens

Trigger: Repairing an install whose recorded merge-json operation has an undefined/missing payload — incomplete state record, schema drift between writer and reader, or a programmatically constructed operation missing `payload`.

Common situations: Partial install-state files from interrupted installs; version mismatch where older states omit payload; manually merged/edited state JSON.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/dba16511313e7104. Report an issue: GitHub.

Appendix: source

Thrown at scripts/lib/install-lifecycle.js:822

      copyContainedFile(sourcePath, operation.destinationPath, trustedRoot, 'repair');
    }
    return operation.destinationPath;
  }

  if (operation.kind === 'render-template') {
    const renderedContent = getOperationTextContent(operation);
    if (renderedContent === null) {
      throw new Error(`Missing rendered content for repair: ${operation.destinationPath}`);
    }

    writeContainedFile(operation.destinationPath, renderedContent, trustedRoot, 'repair');
    return operation.destinationPath;
  }

  if (operation.kind === 'merge-json') {
    const payload = getOperationJsonPayload(operation);
    if (payload === undefined) {
      throw new Error(`Missing merge payload for repair: ${operation.destinationPath}`);
    }

    const existingDestination = getContainedExistingPath(operation.destinationPath, trustedRoot, 'repair');
    const currentValue = existingDestination
      ? readJsonNoFollow(
        getManagedDestination(existingDestination, trustedRoot, 'repair').managedPath
      )
      : {};
    const mergedValue = deepMergeJson(currentValue, payload);

    writeContainedFile(operation.destinationPath, formatJson(mergedValue), trustedRoot, 'repair');
    return operation.destinationPath;
  }

  if (operation.kind === 'update-claude-settings') {
    assertClaudeSettingsDestination(operation, trustedRoot, target);
    const managedHooks = validateManagedHooks(operation.managedHooks);
    const previousManagedHooks = operation.previousManagedHooks

View on GitHub (pinned to 8321021c54)