{"record":{"id":"4f19d66ef6ad3f8b","repo":"pulumi/pulumi","slug":"marshaling-old-inputs-for-resource-error-hook-q","errorCode":null,"errorMessage":"marshaling old inputs for resource error hook %q: %w","messagePattern":"marshaling old inputs for resource error hook %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/resource/deploy/source_eval.go","lineNumber":1959,"sourceCode":"\t\tvar mNewInputs, mOldInputs, mOldOutputs *structpb.Struct\n\t\tmOpts := plugin.MarshalOptions{\n\t\t\tLabel:            fmt.Sprintf(\"ResourceMonitor.ErrorHook(%s, %s)\", name, urn),\n\t\t\tKeepUnknowns:     true,\n\t\t\tKeepSecrets:      true,\n\t\t\tKeepResources:    true,\n\t\t\tKeepOutputValues: true,\n\t\t\tKeepByteString:   cb.AcceptsByteString,\n\t\t}\n\t\tif newInputs != nil {\n\t\t\tmNewInputs, err = plugin.MarshalProperties(newInputs, mOpts)\n\t\t\tif err != nil {\n\t\t\t\treturn false, fmt.Errorf(\"marshaling new inputs for resource error hook %q: %w\", name, err)\n\t\t\t}\n\t\t}\n\t\tif oldInputs != nil {\n\t\t\tmOldInputs, err = plugin.MarshalProperties(oldInputs, mOpts)\n\t\t\tif err != nil {\n\t\t\t\treturn false, fmt.Errorf(\"marshaling old inputs for resource error hook %q: %w\", name, err)\n\t\t\t}\n\t\t}\n\t\tif oldOutputs != nil {\n\t\t\tmOldOutputs, err = plugin.MarshalProperties(oldOutputs, mOpts)\n\t\t\tif err != nil {\n\t\t\t\treturn false, fmt.Errorf(\"marshaling old outputs for resource error hook %q: %w\", name, err)\n\t\t\t}\n\t\t}\n\t\treqBytes, err := proto.Marshal(&pulumirpc.ErrorHookRequest{\n\t\t\tUrn:             string(urn),\n\t\t\tId:              string(id),\n\t\t\tName:            name,\n\t\t\tType:            string(typ),\n\t\t\tNewInputs:       mNewInputs,\n\t\t\tOldInputs:       mOldInputs,\n\t\t\tOldOutputs:      mOldOutputs,\n\t\t\tFailedOperation: failedOperation,\n\t\t\tErrors:          errorMessages,","sourceCodeStart":1941,"sourceCodeEnd":1977,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/pkg/resource/deploy/source_eval.go#L1941-L1977","documentation":"Same family as the new-inputs marshal error: when building the ErrorHookRequest, the engine marshals the resource's old (previous) inputs with plugin.MarshalProperties. Failure means the previous inputs stored in state could not be serialized for the hook callback.","triggerScenarios":"plugin.MarshalProperties(oldInputs, ...) fails while assembling an ErrorHookRequest after a failed resource operation — usually due to corrupt or non-serializable values persisted in the stack state from an earlier deployment.","commonSituations":"Stack state edited by hand (pulumi stack export/import) introducing invalid values; state written by an incompatible older Pulumi version; provider-authored property values with unsupported types.","solutions":["Export the stack (pulumi stack export) and inspect the resource's old inputs for malformed values; fix or remove them and re-import","Delete and recreate the affected resource if its persisted inputs are irrecoverably corrupt","Restore the stack from a backup taken before the corruption","Report/upgrading provider if it is known to emit unserializable values"],"exampleFix":"// before\n$ pulumi stack import --file corrupted.json\n// after\n$ pulumi stack export > s.json  # fix old inputs offline\n$ pulumi stack import --file s.json","handlingStrategy":"validation","validationCode":"// validate persisted old inputs from an exported stack:\nstack, _ := json.Marshal(exportedStack)\n// verify resource inputs contain only scalar/array/object values with valid secret/asset refs","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"marshaling old inputs for resource error hook\") {\n    // export stack, inspect and repair the resource's inputs, then re-import\n}","preventionTips":["Never hand-edit state without validating JSON schema afterwards","Keep stack backups (pulumi stack export) before upgrades","Avoid mixing state files across very different Pulumi versions"],"tags":["serialization","hooks","state","properties"],"backgroundTag":"property-marshal-failed","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}