vitessio/vitess · error

error getting %s in %s: %w

Error message

error getting %s in %s: %w

What it means

This error comes from the vtctldclient code generator tool: after parsing the source package, extractSourceInterface failed to locate/extract the requested interface (flag -type) in the given -source package. main() immediately panics with the wrapped message naming the type and source. It blocks client stub generation, so no new vtctldclient code is produced.

Source

Thrown at go/vt/vtctl/vtctldclient/codegen/main.go:79

	if *out != "" {
		f, err := os.Create(*out)
		if err != nil {
			panic(err)
		}

		defer f.Close()
		output = f
	}

	pkg, err := loadPackage(*source)
	if err != nil {
		panic(err)
	}

	iface, err := extractSourceInterface(pkg, *typeName)
	if err != nil {
		panic(fmt.Errorf("error getting %s in %s: %w", *typeName, *source, err))
	}

	// Pre-seeded imports are hardcoded in the codegen template; seeding them
	// here keeps them out of the generated dynamic import block.
	imports := map[string]string{
		"context": "context",
		"grpc":    "google.golang.org/grpc",
	}
	importNames := []string{}
	funcs := make(map[string]*Func, iface.NumExplicitMethods())
	funcNames := make([]string, iface.NumExplicitMethods())

	for i := 0; i < iface.NumExplicitMethods(); i++ {
		m := iface.ExplicitMethod(i)
		funcNames[i] = m.Name()

		sig, ok := m.Type().(*types.Signature)
		if !ok {

View on GitHub (pinned to 01a25a7d17)

Solutions

  1. Verify the -type flag matches the exact interface name defined in the -source package
  2. Fix the -source path so it points at the package containing the interface
  3. Run codegen via the Makefile target (make codegen) so correct flags are used
  4. If the interface was moved/renamed, update the codegen invocation in the build scripts

Example fix

// before
codegen -source go/vt/vtserverserver -type VtctldServer
// after
codegen -source go/vt/vtctlservice -type VtctldServer
Defensive patterns

Strategy: validation

Validate before calling

// verify the interface exists before running codegen
pkg, err := packages.Load(&packages.Config{Mode: packages.LoadSyntax}, *source)
if err != nil || packages.PrintErrors(pkg) > 0 {
  panic(fmt.Errorf("cannot load %s", *source))
}

Try / catch

iface, err := extractSourceInterface(pkg, *typeName)
if err != nil {
  panic(fmt.Errorf("error getting %s in %s: %w", *typeName, *source, err))
}

Prevention

When it happens

Trigger: Running go/vt/vtctl/vtctldclient/codegen with -source/-type flags where the named interface does not exist in the parsed package, the package fails to load, or the path/type name is misspelled.

Common situations: Renaming or moving the VtctldServer interface without updating codegen flags; running make codegen from a directory where the source path no longer resolves; type moved to another package after refactor.

Related errors


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