apache/beam · error

failed to type check package

Error message

failed to type check package %s

What it means

starcgenx.FromAsts type-checks the parsed Go ASTs with go/types before generating stubs. If conf.Check fails (the package doesn't compile), the SDK cannot resolve identifiers, so it wraps the type-checker error naming the package.

Solutions

  1. Run `go build ./...` (or `go vet`) on the target package first and fix compile errors.
  2. Ensure all imports resolve (go mod tidy) and the generator is run from the module root.
  3. Check that the Go version used to run the generator matches the target package's language version.

Example fix

// before
$ starcgenx -package=broken/pkg -o stubs.go
// after: fix package first
$ go build ./broken/pkg && starcgenx -package=broken/pkg -o stubs.go
Defensive patterns

Strategy: validation

Validate before calling

// Run before invoking the generator:
// go build ./...  (or go vet ./path/to/pkg)
// if it fails, fix compile errors first

Try / catch

if err := starcgenx.FromAsts(e, fset, files); err != nil {
    log.Fatalf("generation aborted: %v — run go build on the package to see the underlying type error", err)
}

Prevention

When it happens

Trigger: Running starcgenx code generation on a package whose files fail to type check — syntax errors, unresolved imports, missing dependencies, or version mismatch between generated code and Go version.

Common situations: Running the generator on an incomplete/generated-in-progress package; GOPATH/module not set up so imports can't be resolved; cross-compiling with an unsupported Go release.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/1c0b67fa13a7b836. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/util/starcgenx/starcgenx.go:153

		conf.IgnoreFuncBodies = true
		if len(e.Ids) != 0 {
			// TODO(lostluck): This becomes unnnecessary iff we can figure out
			// which ParDos are being passed to beam.ParDo or beam.Combine.
			// If there are ids, we need to also look at function bodies, and uses.
			var checkFuncBodies bool
			for _, v := range e.Ids {
				if strings.Contains(v, ".") {
					checkFuncBodies = true
					break
				}
			}
			conf.IgnoreFuncBodies = !checkFuncBodies
			info.Uses = make(map[*ast.Ident]types.Object)
		}
	}

	if _, err := conf.Check(e.Package, fset, files, info); err != nil {
		return errors.Wrapf(err, "failed to type check package %s", e.Package)
	}

	e.Print("/*\n")
	e.Print("CHECKING for RegisterDoFn EXPRs\n")
	visitor := findRegisterDoFnCalls{info, e, make(map[string]bool)}
	for _, file := range files {
		ast.Walk(visitor, file)
	}
	for id := range visitor.idsToFind {
		e.Ids = append(e.Ids, id)
	}

	var idsRequired, idsFound map[string]bool
	if len(e.Ids) > 0 {
		e.Printf("Filtering by %d identifiers: %q\n\n", len(e.Ids), strings.Join(e.Ids, ", "))
		idsRequired = make(map[string]bool)
		idsFound = make(map[string]bool)
		for _, id := range e.Ids {

View on GitHub (pinned to 12126d8942)