{"record":{"id":"188b7259cd4deb24","repo":"dagger/dagger","slug":"failed-to-get-current-module-w","errorCode":null,"errorMessage":"failed to get current module: %w","messagePattern":"failed to get current module: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/client_resource.go","lineNumber":53,"sourceCode":"\th := hmac.New(digest.SHA256.Hash, []byte(scopeDigest))\n\tdt := h.Sum([]byte(externalName))\n\treturn hex.EncodeToString(dt), nil\n}\n\n// CachePerCallerModule scopes a call ID per caller module (using the module's source content digest). If the caller is not in a module, the input is just an empty string.\nvar CachePerCallerModule = dagql.ImplicitInput{\n\tName: \"cachePerCallerModule\",\n\tResolver: func(ctx context.Context, _ map[string]dagql.Input) (dagql.Input, error) {\n\t\tq, err := CurrentQuery(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"current query: %w\", err)\n\t\t}\n\t\tm, err := q.CurrentModule(ctx)\n\t\tif errors.Is(err, ErrNoCurrentModule) {\n\t\t\treturn dagql.NewString(\"mainClient\"), nil\n\t\t}\n\t\tif err != nil {\n\t\t\treturn dagql.NewString(\"\"), fmt.Errorf(\"failed to get current module: %w\", err)\n\t\t}\n\t\tif m.Self() == nil {\n\t\t\treturn dagql.NewString(\"mainClient\"), nil\n\t\t}\n\n\t\tscopedMod, err := ImplementationScopedModule(ctx, m)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tscopeDigest, err := scopedMod.ContentPreferredDigest(ctx)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\treturn dagql.NewString(scopeDigest.String()), nil\n\t},\n}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/client_resource.go#L35-L71","documentation":"After obtaining the query, the CachePerCallerModule resolver calls q.CurrentModule(ctx) to scope the cache key by the caller module's source digest. Any error other than ErrNoCurrentModule is wrapped with this message, meaning module lookup failed unexpectedly and a cache scope cannot be derived (an empty string input is returned to signal failure).","triggerScenarios":"q.CurrentModule(ctx) returns a non-ErrNoCurrentModule error while resolving the cachePerCallerModule implicit input — e.g. internal module state is inconsistent, or module introspection hit a backend failure.","commonSituations":"Calling a cached function during module loading before the module registry is ready; corrupted module metadata in the session; errors surfacing from CurrentModule's own dependency lookups.","solutions":["Check the wrapped inner error to find the CurrentModule failure cause","Ensure the function is called after module initialization completes in the session lifecycle","If the caller legitimately has no module, rely on ErrNoCurrentModule handling — this error indicates a real failure, not a missing module","Retry the operation if the failure was transient (e.g. during session teardown races)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"input, err := resolver(ctx, nil)\nif err != nil {\n    if !errors.Is(err, core.ErrNoCurrentModule) && strings.Contains(err.Error(), \"failed to get current module\") {\n        log.Printf(\"module lookup failed: %v\", err)\n    }\n}","preventionTips":["Call cached functions only after the module session is fully initialized","Check the wrapped cause for transient failures and retry once","Distinguish genuine lookup errors from the benign ErrNoCurrentModule sentinel","Keep module metadata/session state consistent across upgrades"],"tags":["modules","cache-scoping","context"],"backgroundTag":"current-module-lookup-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"}