{"record":{"id":"a08f6c1f258abc1b","repo":"dagger/dagger","slug":"expected-s-to-be-a-function-got-t","errorCode":null,"errorMessage":"expected %s to be a function, got %T","messagePattern":"expected (.+?) to be a function, got %T","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/codegen/generator/go/templates/modules.go","lineNumber":562,"sourceCode":"\t}\n\n\t// Sort methods alphabetically to ensure deterministic codegen output\n\tsort.Slice(methods, func(i, j int) bool {\n\t\treturn methods[i].fn.Name() < methods[j].fn.Name()\n\t})\n\n\tfor _, method := range methods {\n\t\tfnName, sig := method.fn.Name(), method.fn.Type().(*types.Signature)\n\t\tif err := ps.fillObjectFunctionCase(objName, fnName, fnName, sig, method.paramSpecs, cases); err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\t// main module object constructor case\n\tif hasConstructor {\n\t\tsig, ok := ps.constructor.Type().(*types.Signature)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"expected %s to be a function, got %T\", constructorFuncName, ps.constructor.Type())\n\t\t}\n\t\tparamSpecs, err := ps.parseParamSpecs(nil, ps.constructor)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"failed to parse %s function: %w\", constructorFuncName, err)\n\t\t}\n\n\t\t// Validate the constructor returns the main module object (further general validation happens in fillObjectFunctionCase)\n\t\tresults := sig.Results()\n\t\tif results.Len() == 0 {\n\t\t\treturn fmt.Errorf(\"%s must return a value\", constructorFuncName)\n\t\t}\n\t\tresultType := results.At(0).Type()\n\t\tif ptrType, ok := resultType.(*types.Pointer); ok {\n\t\t\tresultType = ptrType.Elem()\n\t\t}\n\t\tresultType = dealias(resultType)\n\t\tnamedType, ok := resultType.(*types.Named)\n\t\tif !ok {","sourceCodeStart":544,"sourceCodeEnd":580,"githubUrl":"https://github.com/dagger/dagger/blob/82ba2681dbe30d3547a1dc50ea495900ab5b6047/cmd/codegen/generator/go/templates/modules.go#L544-L580","documentation":"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.","triggerScenarios":"Thrown at cmd/codegen/generator/go/templates/modules.go:562 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the module's constructor (New) is declared as a plain function","Report if the constructor is valid — likely a codegen bug"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}