apache/beam · error

%s

Error message

%s

What it means

passert.Failures (via failFn) is a test-only DoFn in Apache Beam Go SDK that formats and returns an error when any element reaches it. The error message is the user-supplied format string with the failing element substituted. It is thrown because a pipeline assertion (Equals/Sum/etc.) found data that should not exist, i.e. the assertion failed.

Solutions

  1. Inspect the error message element to find which records failed the assertion
  2. Compare expected vs actual values; fix the transform producing wrong output
  3. If the expected data is wrong, correct the passert expected list/sum in the test
  4. Re-run the pipeline with logging to trace which stage emitted the bad element

Example fix

// before: assertion fails with mismatched element
Equals(p, col, "bad-output")
// after: correct expected value or fix the transform emitting it
Equals(p, col, "good-output")
Defensive patterns

Strategy: try-catch

Try / catch

if err := pipelineRun(); err != nil {
	if strings.Contains(err.Error(), "passert") {
		// assertion failure: log actual vs expected, fail test with context
		t.Fatalf("assertion failed: %v", err)
	}
	return err
}

Prevention

When it happens

Trigger: Running a pipeline with passert.Equals / passert.Sum (or any check that pipes unexpected elements into Failures): an element was emitted downstream and passert routes it to failFn.ProcessElement, which returns errors.Errorf(f.Format, x).

Common situations: Unit/integration tests of Beam pipelines: expected outputs don't match actual outputs due to a broken DoFn, wrong input data, nondeterministic pipeline logic, or incorrect expected fixture values.

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/ded840f2cd7d504f. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/testing/passert/passert.go:168

func fail(s beam.Scope, col beam.PCollection, format string) {
	switch {
	case typex.IsKV(col.Type()):
		beam.ParDo0(s, &failKVFn{Format: format}, col)

	case typex.IsCoGBK(col.Type()):
		beam.ParDo0(s, &failGBKFn{Format: format}, col)

	default:
		beam.ParDo0(s, &failFn{Format: format}, col)
	}
}

type failFn struct {
	Format string `json:"format"`
}

func (f *failFn) ProcessElement(x beam.X) error {
	return errors.Errorf(f.Format, x)
}

type failKVFn struct {
	Format string `json:"format"`
}

func (f *failKVFn) ProcessElement(x beam.X, y beam.Y) error {
	return errors.Errorf(f.Format, fmt.Sprintf("(%v,%v)", x, y))
}

type failGBKFn struct {
	Format string `json:"format"`
}

func (f *failGBKFn) ProcessElement(x beam.X, _ func(*beam.Y) bool) error {
	return errors.Errorf(f.Format, fmt.Sprintf("(%v,*)", x))
}

View on GitHub (pinned to 12126d8942)