pulumi/pulumi · critical

failed to save snapshot: %w

Error message

failed to save snapshot: %w

What it means

Wraps a persister error raised while saving an auto-repaired snapshot in the SnapshotManager's saveSnapshot path. After snapshot integrity verification fails, the manager attempts repair and re-save; if the underlying persister.Save call fails during that repair save, this error wraps the cause with 'failed to save snapshot'.

Source

Thrown at pkg/backend/snapshot.go:868

	integrityError := snapshot.VerifyIntegrity(deployment.Deployment)

	// If we detected a snapshot integrity error, and we have an events channel
	// i.e. in the httpstate backend, try to repair the snapshot.
	var autoRepairErr error
	if integrityError != nil && !DisableIntegrityChecking && sm.events != nil {
		sm.emitSnapshotIntegrityErrorEvent(integrityError)

		repairedDeployment, repairErr := sm.repairAndSerialize()
		if repairErr != nil {
			logging.V(3).Infof("SnapshotManager: failed to repair snapshot: %v", repairErr)
			autoRepairErr = repairErr
		} else if verifyErr := snapshot.VerifyIntegrity(repairedDeployment.Deployment); verifyErr != nil {
			logging.V(3).Infof("SnapshotManager: repaired snapshot still invalid: %v", verifyErr)
			autoRepairErr = verifyErr
		} else {
			repairedDeployment.Deployment.Metadata.IntegrityErrorMetadata = nil
			if err := sm.persister.Save(repairedDeployment); err != nil {
				return fmt.Errorf("failed to save snapshot: %w", err)
			}
			logging.V(3).Infof("SnapshotManager: auto-repaired snapshot integrity error: %v", integrityError)
			return nil
		}
	}

	if integrityError == nil {
		deployment.Deployment.Metadata.IntegrityErrorMetadata = nil
	} else {
		deployment.Deployment.Metadata.IntegrityErrorMetadata = &apitype.SnapshotIntegrityErrorMetadataV1{
			Version: strconv.FormatInt(int64(deployment.Version), 10),
			Command: strings.Join(os.Args, " "),
			Error:   integrityError.Error(),
			EnvVars: utilenv.ConfiguredVariables(),
		}
	}

	if err := sm.persister.Save(deployment); err != nil {

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Inspect the wrapped cause (%w) to find the underlying persister error
  2. Verify credentials/access to the state backend (pulumi login) and retry
  3. Check disk space/permissions if using a local or file backend
  4. Re-run the operation; snapshot auto-repair will be attempted again

Example fix

// before: opaque failure only in CLI output
// after: capture wrapped cause
if err := sm.persister.Save(repairedDeployment); err != nil {
    logging.V(5).Infof("persister.Save failed: %v", err)
    return fmt.Errorf("failed to save snapshot: %w", err)
}
Defensive patterns

Strategy: retry

Validate before calling

// Before relying on auto-repair save, confirm backend is writable
const ok = await isBackendReachable(); // pulumi whoami / storage probe
if (!ok) throw new Error('state backend unavailable; repair save will fail');

Try / catch

try {
  await pulumiUpdate();
} catch (err) {
  if (String(err).includes('failed to save snapshot')) {
    // inspect wrapped cause, re-authenticate, retry once
    await pulumiLogin();
    return retry(pulumiUpdate);
  }
  throw err;
}

Prevention

When it happens

Trigger: An integrity error was detected on the deployment snapshot, repairAndSerialize produced a repaired deployment, and the call to sm.persister.Save(repairedDeployment) returned an error (e.g. backend/storage write failure, serialization rejection, permission or network issue with the state backend).

Common situations: Cloud backend outages or expired credentials while persisting repaired state; corrupted or locked state storage; bucket/file permission errors; disk full on local backends.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/fd2453ad376c4f61. Report an issue: GitHub.