dagger/dagger · error
attach directory withChanges changes
Error message
attach directory withChanges changes: %w
What it means
This error is returned when re-attaching a persisted lazy 'withChanges' directory's Changeset result to the current dagql server fails. After restoring a DirectoryWithChangesLazy from persisted state, both Parent and Changes results must be re-attached by result ID; if the attach call for the Changeset errors (result not found, server lookup failure), this error wraps the cause. It indicates the persisted Changeset result could not be resolved in the running session.
Solutions
- Re-run the pipeline so the Changeset result is recreated in the current session
- Prune and rebuild cache state to clear stale result IDs
- Avoid replaying persisted lazy state across engine restarts or version upgrades
- Fix the wrapped cause (%w) if it points to a specific lookup failure
Example fix
// before: resuming a pipeline after engine restart with stale lazy refs $ dagger run ./ci --resume-from session.json # -> attach directory withChanges changes: result not found // after $ dagger engine prune && dagger run ./ci # rebuild changeset in-session
Defensive patterns
Strategy: retry
Try / catch
// Go
out, err := lazyDir.Export(ctx, path)
if err != nil {
if strings.Contains(err.Error(), "attach directory withChanges changes") {
// stale result: prune cache, rebuild the WithChanges operation, retry once
}
return err
} Prevention
- Avoid resuming persisted lazy state after engine restarts
- Prune cache when result IDs become stale
- Complete pipelines within a single engine session
- Pin engine versions when replaying sessions
When it happens
Trigger: Evaluating a lazy Directory.WithChanges where the persisted Changeset result ID no longer resolves — cache eviction, engine restart, or cross-session replay of persisted lazy state.
Common situations: Replaying a session/call dump against a different engine instance; pruning the cache while lazy references are still pending; version skew where result IDs were persisted under an incompatible scheme.
Related errors
- acquire operation lease
- after ID
- attach directory withChanges changes: unexpected result %T
- container directory lazy: missing mounted directory source…
- container directory lazy: missing mounted directory…
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/2a42abe61ad82fa8.
Report an issue: GitHub.
Appendix: source
Thrown at core/directory.go:1252
return nil, err
}
return json.Marshal(persistedDirectoryDiffLazy{ParentResultID: parentID, OtherResultID: otherID})
}
func (lazy *DirectoryWithChangesLazy) Evaluate(ctx context.Context, dir *Directory) error {
return lazy.LazyState.Evaluate(ctx, "Directory.withChanges", func(ctx context.Context) error {
return dir.WithChanges(ctx, lazy.Parent, lazy.Changes)
})
}
func (lazy *DirectoryWithChangesLazy) AttachDependencies(ctx context.Context, attach func(dagql.AnyResult) (dagql.AnyResult, error)) ([]dagql.AnyResult, error) {
parent, err := attachDirectoryResult(attach, lazy.Parent, "attach directory withChanges parent")
if err != nil {
return nil, err
}
attached, err := attach(lazy.Changes)
if err != nil {
return nil, fmt.Errorf("attach directory withChanges changes: %w", err)
}
changes, ok := attached.(dagql.ObjectResult[*Changeset])
if !ok {
return nil, fmt.Errorf("attach directory withChanges changes: unexpected result %T", attached)
}
lazy.Parent = parent
lazy.Changes = changes
return []dagql.AnyResult{parent, changes}, nil
}
func (lazy *DirectoryWithChangesLazy) EncodePersisted(ctx context.Context, cache dagql.PersistedObjectCache) (json.RawMessage, error) {
parentID, err := encodePersistedObjectRef(cache, lazy.Parent, "directory withChanges parent")
if err != nil {
return nil, err
}
changesID, err := encodePersistedObjectRef(cache, lazy.Changes, "directory withChanges changes")
if err != nil {
return nil, errView on GitHub (pinned to 82ba2681db)