{"record":{"id":"8e959b8547dceae5","repo":"dagger/dagger","slug":"context-directory-id-w","errorCode":null,"errorMessage":"context directory ID: %w","messagePattern":"context directory ID: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/modulesource.go","lineNumber":1516,"sourceCode":"\t//\n\t//   1. a Workspace explicitly bound into the context (an LLM bound via\n\t//      withWorkspace), so the agent's defaultPath args resolve against its\n\t//      own (possibly overlaid) workspace;\n\t//   2. otherwise the module source itself.\n\t//\n\t// NOTE: this applies unilaterally, whether the module was loaded from Host,\n\t// Git, or a Directory.\n\tif ws, ok := WorkspaceFromContext(ctx); ok {\n\t\tinst, err = src.loadContextFromWorkspace(ctx, dag, ws, path, filterInputs)\n\t} else {\n\t\tinst, err = NewModuleSourceFS(nil, src).directory(ctx, dag, path, filterInputs)\n\t}\n\tif err != nil {\n\t\treturn inst, err\n\t}\n\tinstID, err := inst.ID()\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"context directory ID: %w\", err)\n\t}\n\tinstCall, err := inst.ResultCall()\n\tif err != nil {\n\t\treturn inst, fmt.Errorf(\"context directory call: %w\", err)\n\t}\n\tif instID != nil && instCall.ContentDigest() == \"\" {\n\t\tsnapshot, err := inst.Self().Snapshot.GetOrEval(ctx, inst.Result)\n\t\tif err != nil {\n\t\t\treturn inst, fmt.Errorf(\"context directory snapshot: %w\", err)\n\t\t}\n\t\tdirPath, err := inst.Self().Dir.GetOrEval(ctx, inst.Result)\n\t\tif err != nil {\n\t\t\treturn inst, fmt.Errorf(\"context directory path: %w\", err)\n\t\t}\n\t\tdgst, err := GetContentHashFromDirectory(ctx, snapshot, dirPath)\n\t\tif err != nil {\n\t\t\treturn inst, fmt.Errorf(\"failed to content-hash contextual directory: %w\", err)\n\t\t}","sourceCodeStart":1498,"sourceCodeEnd":1534,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/modulesource.go#L1498-L1534","documentation":"Wraps a failure to compute the dagql ID of the Directory instance produced while loading a module source's context directory. The ID is needed to fingerprint the directory call for content-digest caching; if ID derivation fails (invalid/corrupt result, unset dagql instance), this error is returned.","triggerScenarios":"ModuleSource.LoadContextDir is called and the returned Directory dagql instance cannot produce an ID — e.g. the instance result was never properly evaluated or the dagql ID encoding fails.","commonSituations":"Seen during module function execution when resolving contextual (+defaultPath) directories; typically indicates an internal dagql state bug or a corrupted/unsaved Directory instance rather than user error.","solutions":["Inspect the wrapped inner error for the actual ID-encoding failure","Re-run the operation; transient evaluation failures can corrupt the instance","Verify the directory was produced by a valid dagql Select (not manually constructed)","Report upstream with the wrapped error if reproducible in a stock Dagger flow"],"exampleFix":"// before: constructing a Directory outside dagql and passing it through context-dir loading\ninst := dagql.NewInstanceForCurrentOperation(false, dir)\n// after: obtain the directory through the dagql server so ID() succeeds\ndag.Select(ctx, dag.Root(), &inst, dagql.Selector{Field: \"directory\", ...})","handlingStrategy":"try-catch","validationCode":"// Go: verify the directory instance came from a dagql Select before ID()\nif inst.Self() == nil {\n    return fmt.Errorf(\"directory instance uninitialized\")\n}","typeGuard":"func hasID(inst dagql.ObjectResult[*core.Directory]) bool {\n    _, err := inst.ID()\n    return err == nil\n}","tryCatchPattern":"instID, err := inst.ID()\nif err != nil {\n    return nil, fmt.Errorf(\"context directory ID: %w\", err)\n}","preventionTips":["Produce directories via dagql Select rather than manual construction","Retry transient evaluation failures","Capture and report the unwrapped inner error"],"tags":["dagql","directory","id"],"backgroundTag":"dagql-id-derivation-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"}