{"record":{"id":"be4688a00546ddd6","repo":"pulumi/pulumi","slug":"marshalling-checkpoint-w","errorCode":null,"errorMessage":"marshalling checkpoint: %w","messagePattern":"marshalling checkpoint: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/backend/diy/state.go","lineNumber":246,"sourceCode":"\tenc.SetEscapeHTML(false)\n\tif err := enc.Encode(v); err != nil {\n\t\treturn nil, err\n\t}\n\treturn bytes.TrimSpace(buf.Bytes()), nil\n}\n\nfunc (compactJSONMarshaler) Unmarshal(data []byte, v any) error {\n\treturn json.Unmarshal(data, v)\n}\n\nfunc marshalVersionedCheckpoint(\n\tversion int,\n\tfeatures []string,\n\tcheckpoint any,\n) (*apitype.VersionedCheckpoint, error) {\n\tbytes, err := diyJSONMarshaler.Marshal(checkpoint)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"marshalling checkpoint: %w\", err)\n\t}\n\n\treturn &apitype.VersionedCheckpoint{\n\t\tVersion:    version,\n\t\tFeatures:   features,\n\t\tCheckpoint: json.RawMessage(bytes),\n\t}, nil\n}\n\nfunc (b *diyBackend) saveCheckpoint(\n\tctx context.Context,\n\tref *diyBackendReference,\n\tcheckpoint *apitype.VersionedCheckpoint,\n) (backupFile string, file string, _ error) {\n\t// Make a serializable stack and then use the encoder to encode it.\n\t// stackPath does a bucket listing to find which compression variant exists on disk.\n\texistingPath := b.stackPath(ctx, ref)\n\texistingCompression := encoding.CompressionNone","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/backend/diy/state.go#L228-L264","documentation":"marshalVersionedCheckpoint fails when diyJSONMarshaler cannot JSON-marshal the checkpoint object being saved as a VersionedCheckpoint. This is a serialization failure before any file is written, so the wrapped JSON marshal error indicates what part of the checkpoint could not be encoded.","triggerScenarios":"renameStack (or tests) calling saveStack->marshalVersionedCheckpoint with a checkpoint value containing data that cannot be JSON-marshaled, or an internal marshaler failure (e.g. unsupported types, custom marshaler errors).","commonSituations":"Rare in normal use since checkpoints are plain JSON-serializable structures; mostly seen with internal bugs, unexpected types in state, or failures from the secrets marshaler when encrypting/decrypting secrets during re-serialization in renameStack.","solutions":["Inspect the wrapped error to identify the offending field or marshaler failure.","If it involves secrets, verify your secrets provider is reachable and configured correctly (PULUMI_CONFIG_PASSPHRASE or cloud KMS credentials).","Retry the operation; if it persists, report it as a bug with the wrapped error, since checkpoints should always be marshable.","Fall back to `pulumi stack export` to confirm the existing state is readable, and avoid modifying the stack file manually while debugging."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure secrets provider config is present before state-mutating ops\nif (needsPassphraseProvider && !process.env.PULUMI_CONFIG_PASSPHRASE) {\n  throw new Error('PULUMI_CONFIG_PASSPHRASE must be set for this stack');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await pulumi.stack.renameStack(oldName, newName);\n} catch (err) {\n  if (/marshalling checkpoint/.test(err.message)) {\n    // inspect wrapped cause; check secrets provider, retry or report bug\n  } else throw err;\n}","preventionTips":["Keep secrets providers reachable (passphrase/KMS credentials valid) during stack operations","Avoid third-party tools that mutate checkpoint JSON in place","Report persistent marshal failures as bugs with the wrapped cause"],"tags":["serialization","checkpoint","json"],"backgroundTag":"checkpoint-marshal-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}