dagger/dagger · error
decode persisted container withSecretVariable lazy payload:
Error message
decode persisted container withSecretVariable lazy payload: %w
What it means
This error wraps a json.Unmarshal failure decoding the persisted lazy payload for a Container's 'withSecretVariable' operation (from Container.WithSecretVariable). The payload must contain the parent result ID, secret name, and secret result ID; malformed JSON or wrong field types trigger it. It signals incompatible or corrupt persisted lazy state rather than a user API misuse.
Source
Thrown at core/container.go:4579
case "withoutAnnotation":
var persisted persistedContainerWithoutAnnotationLazy
if err := json.Unmarshal(payload, &persisted); err != nil {
return fmt.Errorf("decode persisted container withoutAnnotation lazy payload: %w", err)
}
parent, err := loadPersistedObjectResultByResultID[*Container](ctx, dag, persisted.ParentResultID, "container withoutAnnotation parent")
if err != nil {
return err
}
container.Lazy = &ContainerWithoutAnnotationLazy{
LazyState: NewLazyState(),
Parent: parent,
Name: persisted.Name,
}
return nil
case "withSecretVariable":
var persisted persistedContainerWithSecretVariableLazy
if err := json.Unmarshal(payload, &persisted); err != nil {
return fmt.Errorf("decode persisted container withSecretVariable lazy payload: %w", err)
}
parent, err := loadPersistedObjectResultByResultID[*Container](ctx, dag, persisted.ParentResultID, "container withSecretVariable parent")
if err != nil {
return err
}
secret, err := loadPersistedObjectResultByResultID[*Secret](ctx, dag, persisted.SecretResultID, "container withSecretVariable secret")
if err != nil {
return err
}
container.Lazy = &ContainerWithSecretVariableLazy{
LazyState: NewLazyState(),
Parent: parent,
Name: persisted.Name,
Secret: secret,
}
return nil
case "withoutSecretVariable":
var persisted persistedContainerWithoutSecretVariableLazyView on GitHub (pinned to 82ba2681db)
Solutions
- Prune or reset the Dagger engine cache so the pipeline re-executes and re-persists the lazy state
- Pin the same Dagger version for writing and reading persisted state (schema may have changed between releases)
- Verify engine storage integrity (disk errors, partial writes) and re-run the pipeline
- If reproducible on current versions, report with the inner json.Unmarshal error
Example fix
null
Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
if err := runPipeline(ctx); err != nil {
if strings.Contains(err.Error(), "decode persisted container withSecretVariable lazy payload") {
// invalid persisted lazy payload: clear cache, re-run
exec.Command("dagger", "engine", "prune").Run()
err = runPipeline(ctx)
}
return err
} Prevention
- Upgrade CLI and engine together; never mix versions in one pipeline
- Prune cache after Dagger upgrades before resuming persisted workflows
- Watch for disk-full conditions that cause partial cache writes
- Re-run the pipeline rather than reusing suspicious persisted state
When it happens
Trigger: Hydrating a persisted Container built with WithSecretVariable where the stored JSON does not match persistedContainerWithSecretVariableLazy - e.g. SecretResultID or ParentResultID fields missing, wrong-typed, or payload truncated.
Common situations: Dagger engine upgraded between write and read of the persisted state; corrupted engine cache; a secret result reference record that was garbage-collected or written incorrectly.
Related errors
- decode persisted container withoutSecretVariable lazy payloa
- decode persisted container withoutAnnotation lazy payload: %
- decode persisted container withServiceBinding lazy payload:
- decode persisted container withExposedPort lazy payload: %w
- decode persisted container withoutExposedPort lazy payload:
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/bfb0f71c07480df8.
Report an issue: GitHub.