dagger/dagger · error
lookup constructor %s: %w
Error message
lookup constructor %s: %w
What it means
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.
Source
Thrown at core/sdk/dang/v2/helpers.go:1368
return nil, fmt.Errorf("failed to convert map item %q: %w", name, err)
}
modVal.Bind(name, dangVal, dang.PrivateVisibility)
}
if err := evaluateDangClassBody(ctx, c.env, mod, modVal); err != nil {
return nil, err
}
return modVal, nil
}
func evaluateDangClassBody(ctx context.Context, env dang.ValueScope, mod dang.TypeScope, modVal *dang.Object) error {
if mod.Name() == "" {
return nil
}
constructor, found, err := env.Lookup(ctx, mod.Name())
if err != nil {
return fmt.Errorf("lookup constructor %s: %w", mod.Name(), err)
}
if !found {
return nil
}
constructorFn, ok := constructor.(*dang.ConstructorFunction)
if !ok {
return nil
}
bodyEnv := dang.CreateOverlayValueScope(modVal, env)
bodyEnv.EnterSelf(modVal)
_, err = dang.EvaluateFormsWithPhases(ctx, constructorFn.ObjectBodyForms, bodyEnv)
if err != nil {
return fmt.Errorf("evaluating class body for %s: %w", mod.Name(), err)
}
return nil
}View on GitHub (pinned to 82ba2681db)
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
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the module name resolves cleanly before evaluating the class body
if _, found, err := env.Lookup(ctx, mod.Name()); err != nil {
return fmt.Errorf("environment cannot resolve module %q: %w", mod.Name(), err)
} else if !found {
// constructor absent; body evaluation will be skipped
_ = found
} Try / catch
if err := evaluateDangClassBody(ctx, c.env, mod, modVal); err != nil {
if strings.Contains(err.Error(), "lookup constructor") {
// inspect wrapped cause; re-init or repair the environment scope
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- enum type %s not found in environment
- lookup parent type %s: %w
- unknown parent type: %s
- module %q does not have a scheme for %q
- expected monomorphic type, got %T
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/2b781859edeb9de6.
Report an issue: GitHub.