{"record":{"id":"2b781859edeb9de6","repo":"dagger/dagger","slug":"lookup-constructor-s-w-2b7818","errorCode":null,"errorMessage":"lookup constructor %s: %w","messagePattern":"lookup constructor (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/sdk/dang/v2/helpers.go","lineNumber":1368,"sourceCode":"\t\t\treturn nil, fmt.Errorf(\"failed to convert map item %q: %w\", name, err)\n\t\t}\n\t\tmodVal.Bind(name, dangVal, dang.PrivateVisibility)\n\t}\n\n\tif err := evaluateDangClassBody(ctx, c.env, mod, modVal); err != nil {\n\t\treturn nil, err\n\t}\n\treturn modVal, nil\n}\n\nfunc evaluateDangClassBody(ctx context.Context, env dang.ValueScope, mod dang.TypeScope, modVal *dang.Object) error {\n\tif mod.Name() == \"\" {\n\t\treturn nil\n\t}\n\n\tconstructor, found, err := env.Lookup(ctx, mod.Name())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"lookup constructor %s: %w\", mod.Name(), err)\n\t}\n\tif !found {\n\t\treturn nil\n\t}\n\n\tconstructorFn, ok := constructor.(*dang.ConstructorFunction)\n\tif !ok {\n\t\treturn nil\n\t}\n\n\tbodyEnv := dang.CreateOverlayValueScope(modVal, env)\n\tbodyEnv.EnterSelf(modVal)\n\t_, err = dang.EvaluateFormsWithPhases(ctx, constructorFn.ObjectBodyForms, bodyEnv)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"evaluating class body for %s: %w\", mod.Name(), err)\n\t}\n\treturn nil\n}","sourceCodeStart":1350,"sourceCodeEnd":1386,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/core/sdk/dang/v2/helpers.go#L1350-L1386","documentation":"evaluateDangClassBody resolves the module's constructor by looking up the module's own name in the environment. If the environment lookup itself errors (as opposed to simply not finding the name, which is tolerated), this error wraps that failure with the module name. It only fires on real lookup errors — scope corruption, evaluation failure in the environment — not on missing constructors.","triggerScenarios":"Converting/building a named module whose class body is evaluated while the environment's Lookup returns an error, e.g. because parent scope evaluation failed or the scope chain is broken.","commonSituations":"A module whose name collides with a broken binding in an enclosing scope; a partially-initialized environment during SDK module loading; upstream errors in scope setup surfacing at class-body evaluation.","solutions":["Inspect the wrapped %w cause — it names the underlying environment lookup failure","Verify the module name does not shadow a broken/erroneous binding in an enclosing scope","Ensure the environment/scope chain is fully initialized before converting the module"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the module name resolves cleanly before evaluating the class body\nif _, found, err := env.Lookup(ctx, mod.Name()); err != nil {\n\treturn fmt.Errorf(\"environment cannot resolve module %q: %w\", mod.Name(), err)\n} else if !found {\n\t// constructor absent; body evaluation will be skipped\n\t_ = found\n}","typeGuard":null,"tryCatchPattern":"if err := evaluateDangClassBody(ctx, c.env, mod, modVal); err != nil {\n\tif strings.Contains(err.Error(), \"lookup constructor\") {\n\t\t// inspect wrapped cause; re-init or repair the environment scope\n\t}\n\treturn err\n}","preventionTips":["Fully initialize the environment/scope chain before converting modules","Avoid module names that shadow broken bindings in enclosing scopes","Log and resolve any upstream scope errors before module loading"],"tags":["dang","module","lookup","scope"],"backgroundTag":"environment-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"}