vitessio/vitess · error

no type called '%s' found in '%s'

Error message

no type called '%s' found in '%s'

What it means

findTypeObject found the package scope but scope.Lookup(typename) returned nil, meaning no type with that exact name exists (or is exported) in that package. It throws this error naming the type and package.

Source

Thrown at go/tools/asthelpergen/asthelpergen.go:333

// findTypeObject finds the types.Object for the given interface from the given scopes.
func findTypeObject(interfaceToFind string, scopes map[string]*types.Scope) (types.Object, error) {
	pos := strings.LastIndexByte(interfaceToFind, '.')
	if pos < 0 {
		return nil, fmt.Errorf("unexpected input type: %s", interfaceToFind)
	}

	pkgname := interfaceToFind[:pos]
	typename := interfaceToFind[pos+1:]

	scope := scopes[pkgname]
	if scope == nil {
		return nil, fmt.Errorf("no scope found for type '%s'", interfaceToFind)
	}

	tt := scope.Lookup(typename)
	if tt == nil {
		return nil, fmt.Errorf("no type called '%s' found in '%s'", typename, pkgname)
	}
	return tt, nil
}

var _ generatorSPI = (*astHelperGen)(nil)

func (gen *astHelperGen) scope() *types.Scope {
	return gen._scope
}

func (gen *astHelperGen) addType(t types.Type) {
	gen.todo = append(gen.todo, t)
}

func (gen *astHelperGen) createFiles() (map[string]*jen.File, error) {
	if err := gen.processTypeQueue(); err != nil {
		return nil, err
	}

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Correct the type name in Options to the exact exported identifier
  2. Check the package source for the current name (or run `go doc <pkg>` to list types)
  3. If the type was removed, remove or replace the corresponding generator configuration

Example fix

// before
"vitess.io/vitess/go/vt/sqlparser.Visitible"
// after
"vitess.io/vitess/go/vt/sqlparser.Visitable"
Defensive patterns

Strategy: validation

Validate before calling

// check the type exists before invoking codegen
scope := scopes[pkgPath]
if scope != nil && scope.Lookup(typeName) == nil {
    return fmt.Errorf("type %s not found in %s; fix Options", typeName, pkgPath)
}

Type guard

func typeExists(scopes map[string]*types.Scope, iface string) bool {
    i := strings.LastIndexByte(iface, '.')
    sc := scopes[iface[:i]]
    return sc != nil && sc.Lookup(iface[i+1:]) != nil
}

Prevention

When it happens

Trigger: Interface name typo like 'sqlparser.SQLNod' or 'sqlparser.Visitible'; referencing a type that was renamed or removed from the package.

Common situations: Typo in Options.Visitable list; interface renamed during a refactor while generator config still references the old name.

Related errors


AI-assisted analysis of vitessio/vitess@01a25a7d17 (2026-09-01). Data as JSON: /api/errors/84e660271d54f1c3. Report an issue: GitHub.