Skip to content

Partial deploy failure loses harness state — can create duplicate resources #1382

@jariy17

Description

@jariy17

Problem

If deploying harness B fails after harness A succeeds, the partial state (containing harness A's new ID) is never persisted to disk.

Flow:

  1. HarnessDeployer.deploy() returns { success: false, state: resultState }resultState contains harness A's ID
  2. actions.ts:531 extracts the state into deployedHarnesses
  3. actions.ts:541 returns early with an error — before writeDeployedState() at line 584

On next deploy attempt, the state file doesn't know harness A exists. The deployer takes the CREATE path (createHarness with clientToken: randomUUID()), producing a duplicate cloud resource. The previous harness A is orphaned.

Expected behavior

Partial state should be persisted even on failure, so the next deploy attempt can UPDATE existing harnesses rather than re-creating them.

Possible fix

Write deployed state before the early return at line 541:

if (harnessDeployError) {
  // Persist partial state so successfully-created harnesses aren't orphaned
  await configIO.writeDeployedState(buildDeployedState(...));
  return { success: false, error: harnessDeployError };
}

Context

Found during review of #1341.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions