dagger/dagger · error
expected %s to be a function, got %T
Error message
expected %s to be a function, got %T
What it means
Defensive assertion in fillObjectFunctionCases: the stored constructor's type is not a *types.Signature. Should be unreachable since constructors are validated as functions earlier; indicates internal parse-state inconsistency.
Source
Thrown at cmd/codegen/generator/go/templates/modules.go:562
}
// Sort methods alphabetically to ensure deterministic codegen output
sort.Slice(methods, func(i, j int) bool {
return methods[i].fn.Name() < methods[j].fn.Name()
})
for _, method := range methods {
fnName, sig := method.fn.Name(), method.fn.Type().(*types.Signature)
if err := ps.fillObjectFunctionCase(objName, fnName, fnName, sig, method.paramSpecs, cases); err != nil {
return err
}
}
// main module object constructor case
if hasConstructor {
sig, ok := ps.constructor.Type().(*types.Signature)
if !ok {
return fmt.Errorf("expected %s to be a function, got %T", constructorFuncName, ps.constructor.Type())
}
paramSpecs, err := ps.parseParamSpecs(nil, ps.constructor)
if err != nil {
return fmt.Errorf("failed to parse %s function: %w", constructorFuncName, err)
}
// Validate the constructor returns the main module object (further general validation happens in fillObjectFunctionCase)
results := sig.Results()
if results.Len() == 0 {
return fmt.Errorf("%s must return a value", constructorFuncName)
}
resultType := results.At(0).Type()
if ptrType, ok := resultType.(*types.Pointer); ok {
resultType = ptrType.Elem()
}
resultType = dealias(resultType)
namedType, ok := resultType.(*types.Named)
if !ok {View on GitHub (pinned to 82ba2681db)
Solutions
- Check the module's constructor (New) is declared as a plain function
- Report if the constructor is valid — likely a codegen bug
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at cmd/codegen/generator/go/templates/modules.go:562 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/a08f6c1f258abc1b.
Report an issue: GitHub.