{"record":{"id":"bdc12ec353de7f03","repo":"dagger/dagger","slug":"module-provenance-implementation-scoped-module-q-bdc12e","errorCode":null,"errorMessage":"module provenance: implementation-scoped module %q is not attached","messagePattern":"module provenance: implementation-scoped module %q is not attached","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/module.go","lineNumber":2338,"sourceCode":"func (mod *userMod) ResultCallModule(ctx context.Context) (*dagql.ResultCallModule, error) {\n\tself := mod.self()\n\tif self == nil {\n\t\treturn nil, fmt.Errorf(\"module provenance: missing module result wrapper\")\n\t}\n\tif !self.Source.Valid {\n\t\treturn nil, fmt.Errorf(\"module provenance: module %q has no source\", self.Name())\n\t}\n\n\tscoped, err := ImplementationScopedModule(ctx, mod.res)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"module provenance: implementation-scoped module %q: %w\", self.Name(), err)\n\t}\n\tscopedID, err := scoped.ID()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"module provenance: module %q handle ID: %w\", self.Name(), err)\n\t}\n\tif scopedID == nil || scopedID.EngineResultID() == 0 {\n\t\treturn nil, fmt.Errorf(\"module provenance: implementation-scoped module %q is not attached\", self.Name())\n\t}\n\n\tsrc := self.Source.Value.Self()\n\tvar ref, pin string\n\tswitch src.Kind {\n\tcase ModuleSourceKindLocal:\n\t\tref = filepath.Join(src.Local.ContextDirectoryPath, src.SourceRootSubpath)\n\tcase ModuleSourceKindGit:\n\t\tref = src.Git.CloneRef\n\t\tif src.SourceRootSubpath != \"\" {\n\t\t\tref += \"/\" + strings.TrimPrefix(src.SourceRootSubpath, \"/\")\n\t\t}\n\t\tif src.Git.Version != \"\" {\n\t\t\tref += \"@\" + src.Git.Version\n\t\t}\n\t\tpin = src.Git.Commit\n\tcase ModuleSourceKindDir:\n\tdefault:","sourceCodeStart":2320,"sourceCodeEnd":2356,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/module.go#L2320-L2356","documentation":"During module provenance computation (ResultCallModule), Dagger wraps the user module in an implementation-scoped handle and requires that handle to carry an EngineResultID. If the scoped ID is nil or its engine result ID is 0, the module instance was never attached to the engine's result/call graph, so its provenance (ref, pin, result reference) cannot be reconstructed. This is an internal consistency check guarding against emitting provenance metadata for an unattached module.","triggerScenarios":"Calling ResultCallModule (e.g. while building a function-call provenance record for Dagger Cloud / engine telemetry) on a userMod whose implementation-scoped module ID is nil or whose EngineResultID() is 0 — i.e. the module was instantiated without being registered as an engine result.","commonSituations":"Running a module function in an engine/CLI version mismatch where the result-call plumbing didn't attach the module; calling engine internals out of order in custom code; telemetry/provenance emission for a module created programmatically rather than via the normal module-loading path.","solutions":["Upgrade the dagger CLI and engine to matching, current versions so module instances are attached with engine result IDs as expected","Retry the operation — if it came from a stale/cached module handle, re-load the module (fresh dagger connect / ModuleSource resolution)","If you are developing engine code, ensure ImplementationScopedModule output is ID()'d only after the module result has been registered via the dagql server","File a bug with the dagger trace/telemetry if it reproduces on current versions; this path should be unreachable in normal flows"],"exampleFix":"// before (internal flow, conceptually)\nscopedID, _ := scoped.ID()\nuse(scopedID) // panics/errors later: nil / EngineResultID()==0\n// after\nif scopedID == nil || scopedID.EngineResultID() == 0 {\n    return nil, fmt.Errorf(\"module provenance: implementation-scoped module %q is not attached\", self.Name())\n}\nuse(scopedID)","handlingStrategy":"retry","validationCode":"// before relying on provenance\nid, err := scoped.ID()\nif err != nil || id == nil || id.EngineResultID() == 0 {\n    // re-load module via normal load path before emitting provenance\n}","typeGuard":null,"tryCatchPattern":"// Go\nres, err := mod.ResultCallModule(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"is not attached\") {\n        // re-load module / retry once with a fresh session\n    }\n    return err\n}","preventionTips":["Keep dagger CLI and engine versions in lockstep","Always load modules through the standard module-loading path","Re-load module handles instead of caching them across sessions"],"tags":["dagger","modules","provenance","internal-state"],"backgroundTag":"module-not-attached","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"}