vitessio/vitess · error
expected a named type for %s, got %v
Error message
expected a named type for %s, got %v
What it means
extractLocalNamedType expects each *types.Var (a function/method parameter) to have a named type so the generator can map it to a local proto import and render type arguments. This error means the parameter's type is unnamed (basic type, slice, map, unnamed struct, or unnamed pointer target chain), which the template generator does not support.
Source
Thrown at go/vt/vtctl/vtctldclient/codegen/main.go:358
}
return nil, fmt.Errorf("symbol %s was not an interface but %T", name, obj.Type())
}
var vitessProtoRegexp = regexp.MustCompile(`^vitess\.io.*/proto/.*`)
func rewriteProtoImports(pkg *types.Package) string {
if vitessProtoRegexp.MatchString(pkg.Path()) {
return pkg.Name() + "pb"
}
return pkg.Name()
}
func extractLocalNamedType(v *types.Var) (name string, localImport string, pkgPath string, argImports []typeArgImport, err error) {
named, ok := v.Type().(*types.Named)
if !ok {
return "", "", "", nil, fmt.Errorf("expected a named type for %s, got %v", v.Name(), v.Type())
}
typeArgs, argImports, err := renderTypeArgs(named)
if err != nil {
return "", "", "", nil, err
}
name = named.Obj().Name() + typeArgs
localImport = rewriteProtoImports(named.Obj().Pkg())
pkgPath = named.Obj().Pkg().Path()
return name, localImport, pkgPath, argImports, nil
}
// typeArgImport describes an import required by a type argument of an
// instantiated generic type.
type typeArgImport struct {
localImport stringView on GitHub (pinned to 01a25a7d17)
Solutions
- Change the interface method parameter to a named type (e.g. a proto message pointer or named generic instantiation)
- If the parameter must stay primitive, extend the codegen tool to handle that type kind
- Revert recent signature changes to the interface before running codegen
Example fix
// before DoThing(ctx context.Context, names map[string]string) error // after DoThing(ctx context.Context, req *vtctldatapb.DoThingRequest) error
Defensive patterns
Strategy: validation
Validate before calling
// Audit interface method params for named types before codegen
for i := 0; i < sig.Params().Len(); i++ {
if _, ok := sig.Params().At(i).Type().(*types.Named); !ok {
return fmt.Errorf("param %d of %s is not a named type", i, fn)
}
} Type guard
func isNamedParam(v *types.Var) bool {
_, ok := v.Type().(*types.Named)
return ok
} Prevention
- Keep interface method params as proto message types or named generic instantiations
- Run codegen immediately after signature edits so failures map to the recent change
When it happens
Trigger: The source interface being processed has a method whose parameter is not a named type or *types.Named generic instantiation — e.g. takes a string, []byte, map[K]V, or a non-generic unnamed type.
Common situations: Adding a method to the source interface with primitive/composite parameters and then running vtctldclient codegen; changing a method signature to use context.Context-style unnamed generics or plain types the codegen does not handle; the anonymous <anonymous> caller path is when renderTypeArgs or the main flow processes a var from a method signature.
Related errors
- expected a named type for type argument %d of %s, got %v
- symbol %s was not an interface but %T
- expected a pointer type for %s, got %v
- expected an underlying named type for %s, got %v
- package '%s' does not contain 'ast_format.go'
AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01).
Data as JSON: /api/errors/976fd04976221a1f.
Report an issue: GitHub.