{"record":{"id":"59543fb58b4f13e3","repo":"dagger/dagger","slug":"decode-persisted-container-s-lazy-payload-w","errorCode":null,"errorMessage":"decode persisted container %s lazy payload: %w","messagePattern":"decode persisted container (.+?) lazy payload: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/container.go","lineNumber":4749,"sourceCode":"\t\t\treturn err\n\t\t}\n\t\tsource, err := loadPersistedObjectResultByResultID[*Directory](ctx, dag, persisted.SourceResultID, \"container withDirectory source\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcontainer.Lazy = &ContainerWithDirectoryLazy{\n\t\t\tLazyState: NewLazyState(),\n\t\t\tParent:    parent,\n\t\t\tPath:      persisted.Path,\n\t\t\tSource:    source,\n\t\t\tFilter:    persisted.Filter,\n\t\t\tOwner:     persisted.Owner,\n\t\t}\n\t\treturn nil\n\tcase \"withFile\", \"withNewFile\":\n\t\tvar persisted persistedContainerWithFileLazy\n\t\tif err := json.Unmarshal(payload, &persisted); err != nil {\n\t\t\treturn fmt.Errorf(\"decode persisted container %s lazy payload: %w\", call.Field, err)\n\t\t}\n\t\tparent, err := loadPersistedObjectResultByResultID[*Container](ctx, dag, persisted.ParentResultID, \"container \"+call.Field+\" parent\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tsource, err := loadPersistedObjectResultByResultID[*File](ctx, dag, persisted.SourceResultID, \"container \"+call.Field+\" source\")\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tcontainer.Lazy = &ContainerWithFileLazy{\n\t\t\tLazyState:   NewLazyState(),\n\t\t\tParent:      parent,\n\t\t\tPath:        persisted.Path,\n\t\t\tSource:      source,\n\t\t\tPermissions: persisted.Permissions,\n\t\t\tOwner:       persisted.Owner,\n\t\t}\n\t\treturn nil","sourceCodeStart":4731,"sourceCodeEnd":4767,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/container.go#L4731-L4767","documentation":"This error is returned when the Dagger engine tries to lazily rehydrate a persisted Container result for the withFile/withNewFile call, but the JSON blob stored in the persisted lazy payload cannot be unmarshaled into persistedContainerWithFileLazy. It indicates the stored payload is corrupt, truncated, or was written by an incompatible engine/schema version. The wrap preserves the underlying json.Unmarshal error (syntax error, type mismatch, unknown/missing fields affecting decoding).","triggerScenarios":"Replaying or loading a persisted container from the engine's result cache whose withFile/withNewFile lazy payload fails json.Unmarshal into persistedContainerWithFileLazy — e.g. malformed JSON on disk, ParentResultID/SourceResultID fields of the wrong JSON type, or a payload written by a different Dagger version with a changed schema.","commonSituations":"Upgrading or downgrading Dagger between versions where the persisted lazy-payload struct changed; a corrupted cache volume (disk corruption, partial write, crash during persist); manually tampering with or copying cache data between engines; restoring cache from a backup with truncated files.","solutions":["Clear the Dagger engine cache so corrupted payloads are regenerated (dagger core-engine restart / prune cache) and re-run the pipeline.","Upgrade (or align) the dagger CLI and engine to matching versions so the persisted schema matches the reader.","Inspect the underlying wrapped json error to identify the exact field/type mismatch (jq-validate the stored payload if you can locate it in the cache).","If reproducible after cache clear, report with the payload shape; as a workaround disable result persistence/replay for the session.","Reproduce with a fresh engine (fresh container/host) to rule out host disk corruption."],"exampleFix":"// before (shell)\ndagger run ./ci.mts\n// after — reset corrupted cached payloads\ndagger query <<'EOF'\n{ container { from(address:\"alpine\") { withFile(path:\"/x\", source: scratchFileId) { id } } } }\nEOF\n# or prune the engine cache, then re-run","handlingStrategy":"retry","validationCode":"// before replaying persisted results, verify engine version and cache health\ndg := dagger.Connect()\nv, err := dg.Container().From(\"registry.dagger.io/engine\").WithExec([]string{\"--version\"}).Sync(ctx)\nif err != nil { /* skip replay, rebuild fresh */ }\n// optionally: if errors persist, drop the engine cache volume before the run","typeGuard":null,"tryCatchPattern":"container, err := c.WithFile(path, src).Sync(ctx)\nvar serr *json.SyntaxError\nif err != nil && strings.Contains(err.Error(), \"decode persisted container withFile lazy payload\") {\n    // corrupt persisted payload: clear cache & rebuild fresh instead of retrying same blob\n    os.RemoveAll(engineCacheDir) // or restart engine\n    container, err = c.WithFile(path, src).Sync(ctx)\n}\nreturn container, err","preventionTips":["Keep dagger CLI and engine on identical versions","Restart/prune engine caches after upgrading Dagger","Avoid sharing persisted-result caches across Dagger versions","Monitor disks for corruption in CI runners (fsck, checksums on cache backups)","Wrap cache-replay paths with error classification that falls back to fresh execution"],"tags":["json","serialization","cache","dagger","container"],"backgroundTag":"persisted-payload-decode-failed","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}