{"record":{"id":"fd2453ad376c4f61","repo":"pulumi/pulumi","slug":"failed-to-save-snapshot-w-fd2453","errorCode":null,"errorMessage":"failed to save snapshot: %w","messagePattern":"failed to save snapshot: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/backend/snapshot.go","lineNumber":868,"sourceCode":"\tintegrityError := snapshot.VerifyIntegrity(deployment.Deployment)\n\n\t// If we detected a snapshot integrity error, and we have an events channel\n\t// i.e. in the httpstate backend, try to repair the snapshot.\n\tvar autoRepairErr error\n\tif integrityError != nil && !DisableIntegrityChecking && sm.events != nil {\n\t\tsm.emitSnapshotIntegrityErrorEvent(integrityError)\n\n\t\trepairedDeployment, repairErr := sm.repairAndSerialize()\n\t\tif repairErr != nil {\n\t\t\tlogging.V(3).Infof(\"SnapshotManager: failed to repair snapshot: %v\", repairErr)\n\t\t\tautoRepairErr = repairErr\n\t\t} else if verifyErr := snapshot.VerifyIntegrity(repairedDeployment.Deployment); verifyErr != nil {\n\t\t\tlogging.V(3).Infof(\"SnapshotManager: repaired snapshot still invalid: %v\", verifyErr)\n\t\t\tautoRepairErr = verifyErr\n\t\t} else {\n\t\t\trepairedDeployment.Deployment.Metadata.IntegrityErrorMetadata = nil\n\t\t\tif err := sm.persister.Save(repairedDeployment); err != nil {\n\t\t\t\treturn fmt.Errorf(\"failed to save snapshot: %w\", err)\n\t\t\t}\n\t\t\tlogging.V(3).Infof(\"SnapshotManager: auto-repaired snapshot integrity error: %v\", integrityError)\n\t\t\treturn nil\n\t\t}\n\t}\n\n\tif integrityError == nil {\n\t\tdeployment.Deployment.Metadata.IntegrityErrorMetadata = nil\n\t} else {\n\t\tdeployment.Deployment.Metadata.IntegrityErrorMetadata = &apitype.SnapshotIntegrityErrorMetadataV1{\n\t\t\tVersion: strconv.FormatInt(int64(deployment.Version), 10),\n\t\t\tCommand: strings.Join(os.Args, \" \"),\n\t\t\tError:   integrityError.Error(),\n\t\t\tEnvVars: utilenv.ConfiguredVariables(),\n\t\t}\n\t}\n\n\tif err := sm.persister.Save(deployment); err != nil {","sourceCodeStart":850,"sourceCodeEnd":886,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/backend/snapshot.go#L850-L886","documentation":"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'.","triggerScenarios":"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).","commonSituations":"Cloud backend outages or expired credentials while persisting repaired state; corrupted or locked state storage; bucket/file permission errors; disk full on local backends.","solutions":["Inspect the wrapped cause (%w) to find the underlying persister error","Verify credentials/access to the state backend (pulumi login) and retry","Check disk space/permissions if using a local or file backend","Re-run the operation; snapshot auto-repair will be attempted again"],"exampleFix":"// before: opaque failure only in CLI output\n// after: capture wrapped cause\nif err := sm.persister.Save(repairedDeployment); err != nil {\n    logging.V(5).Infof(\"persister.Save failed: %v\", err)\n    return fmt.Errorf(\"failed to save snapshot: %w\", err)\n}","handlingStrategy":"retry","validationCode":"// Before relying on auto-repair save, confirm backend is writable\nconst ok = await isBackendReachable(); // pulumi whoami / storage probe\nif (!ok) throw new Error('state backend unavailable; repair save will fail');","typeGuard":null,"tryCatchPattern":"try {\n  await pulumiUpdate();\n} catch (err) {\n  if (String(err).includes('failed to save snapshot')) {\n    // inspect wrapped cause, re-authenticate, retry once\n    await pulumiLogin();\n    return retry(pulumiUpdate);\n  }\n  throw err;\n}","preventionTips":["Keep backend credentials valid (re-run pulumi login before long CI jobs)","Monitor state-backend storage quotas and permissions","Avoid manually editing snapshot state","Snapshot state backups so failed saves are recoverable"],"tags":["state","snapshot","persistence","autorepair"],"backgroundTag":"snapshot-save-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}