{"record":{"id":"2a42abe61ad82fa8","repo":"dagger/dagger","slug":"attach-directory-withchanges-changes-w","errorCode":null,"errorMessage":"attach directory withChanges changes: %w","messagePattern":"attach directory withChanges changes: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/directory.go","lineNumber":1252,"sourceCode":"\t\treturn nil, err\n\t}\n\treturn json.Marshal(persistedDirectoryDiffLazy{ParentResultID: parentID, OtherResultID: otherID})\n}\n\nfunc (lazy *DirectoryWithChangesLazy) Evaluate(ctx context.Context, dir *Directory) error {\n\treturn lazy.LazyState.Evaluate(ctx, \"Directory.withChanges\", func(ctx context.Context) error {\n\t\treturn dir.WithChanges(ctx, lazy.Parent, lazy.Changes)\n\t})\n}\n\nfunc (lazy *DirectoryWithChangesLazy) AttachDependencies(ctx context.Context, attach func(dagql.AnyResult) (dagql.AnyResult, error)) ([]dagql.AnyResult, error) {\n\tparent, err := attachDirectoryResult(attach, lazy.Parent, \"attach directory withChanges parent\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tattached, err := attach(lazy.Changes)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"attach directory withChanges changes: %w\", err)\n\t}\n\tchanges, ok := attached.(dagql.ObjectResult[*Changeset])\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"attach directory withChanges changes: unexpected result %T\", attached)\n\t}\n\tlazy.Parent = parent\n\tlazy.Changes = changes\n\treturn []dagql.AnyResult{parent, changes}, nil\n}\n\nfunc (lazy *DirectoryWithChangesLazy) EncodePersisted(ctx context.Context, cache dagql.PersistedObjectCache) (json.RawMessage, error) {\n\tparentID, err := encodePersistedObjectRef(cache, lazy.Parent, \"directory withChanges parent\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tchangesID, err := encodePersistedObjectRef(cache, lazy.Changes, \"directory withChanges changes\")\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":1234,"sourceCodeEnd":1270,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/directory.go#L1234-L1270","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: resuming a pipeline after engine restart with stale lazy refs\n$ dagger run ./ci --resume-from session.json  # -> attach directory withChanges changes: result not found\n// after\n$ dagger engine prune && dagger run ./ci  # rebuild changeset in-session","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go\nout, err := lazyDir.Export(ctx, path)\nif err != nil {\n    if strings.Contains(err.Error(), \"attach directory withChanges changes\") {\n        // stale result: prune cache, rebuild the WithChanges operation, retry once\n    }\n    return err\n}","preventionTips":["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"],"tags":["cache","lazy-evaluation","serialization"],"backgroundTag":"stale-cache-result-reference","analyzedSha":"82ba2681dbe30d3547a1dc50ea495900ab5b6047","analyzedAt":"2026-09-05T07:21:37.930Z","contentChangedAt":"2026-09-05T07:21:37.930Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}