dagger/dagger · error
decode persisted container %s lazy payload: %w
Error message
decode persisted container %s lazy payload: %w
What it means
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).
Source
Thrown at core/container.go:4749
return err
}
source, err := loadPersistedObjectResultByResultID[*Directory](ctx, dag, persisted.SourceResultID, "container withDirectory source")
if err != nil {
return err
}
container.Lazy = &ContainerWithDirectoryLazy{
LazyState: NewLazyState(),
Parent: parent,
Path: persisted.Path,
Source: source,
Filter: persisted.Filter,
Owner: persisted.Owner,
}
return nil
case "withFile", "withNewFile":
var persisted persistedContainerWithFileLazy
if err := json.Unmarshal(payload, &persisted); err != nil {
return fmt.Errorf("decode persisted container %s lazy payload: %w", call.Field, err)
}
parent, err := loadPersistedObjectResultByResultID[*Container](ctx, dag, persisted.ParentResultID, "container "+call.Field+" parent")
if err != nil {
return err
}
source, err := loadPersistedObjectResultByResultID[*File](ctx, dag, persisted.SourceResultID, "container "+call.Field+" source")
if err != nil {
return err
}
container.Lazy = &ContainerWithFileLazy{
LazyState: NewLazyState(),
Parent: parent,
Path: persisted.Path,
Source: source,
Permissions: persisted.Permissions,
Owner: persisted.Owner,
}
return nilView on GitHub (pinned to 82ba2681db)
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.
Example fix
// before (shell)
dagger run ./ci.mts
// after — reset corrupted cached payloads
dagger query <<'EOF'
{ container { from(address:"alpine") { withFile(path:"/x", source: scratchFileId) { id } } } }
EOF
# or prune the engine cache, then re-run Defensive patterns
Strategy: retry
Validate before calling
// before replaying persisted results, verify engine version and cache health
dg := dagger.Connect()
v, err := dg.Container().From("registry.dagger.io/engine").WithExec([]string{"--version"}).Sync(ctx)
if err != nil { /* skip replay, rebuild fresh */ }
// optionally: if errors persist, drop the engine cache volume before the run Try / catch
container, err := c.WithFile(path, src).Sync(ctx)
var serr *json.SyntaxError
if err != nil && strings.Contains(err.Error(), "decode persisted container withFile lazy payload") {
// corrupt persisted payload: clear cache & rebuild fresh instead of retrying same blob
os.RemoveAll(engineCacheDir) // or restart engine
container, err = c.WithFile(path, src).Sync(ctx)
}
return container, err Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- decode persisted container withMountedDirectory lazy payload
- decode persisted container withMountedFile lazy payload: %w
- decode persisted container withMountedPathDockerfileCompat l
- decode persisted container withMountedCache lazy payload: %w
- decode persisted container withMountedVolume lazy payload: %
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/59543fb58b4f13e3.
Report an issue: GitHub.