apache/beam · error
passert.Sum( ) = , want
Error message
passert.Sum(%v) = {%v, size: %v}, want {%v, size:%v} What it means
passert.Sum's verification DoFn iterates all values for the named sum, computes the actual sum and count, and errors when they differ from the expected Sum and Size recorded at passert.Sum(...) time. The message includes name, actual {sum, size}, and expected {sum, size} so the mismatch is immediately diagnosable.
Solutions
- Read actual vs expected {sum, size} from the message
- If size differs, find why element count changed (extra/dropped records)
- If only sum differs, find why values changed
- Update the expected sum/size in the test if the new output is correct
Example fix
// before passert.Sum(p, "sums", col, 10) // actual 12 // after passert.Sum(p, "sums", col, 12)
Defensive patterns
Strategy: try-catch
Try / catch
if err := pr.Wait(); err != nil {
var want, got int
if _, scanErr := fmt.Sscanf(err.Error(), "passert.Sum(%s", new(string)); scanErr == nil {
t.Fatalf("sum mismatch: %v", err)
}
return err
} Prevention
- Compute expected sums from the input dataset programmatically
- Check element counts before sums to catch missing records
- Recompute expected values when input data changes
When it happens
Trigger: Calling passert.Sum(p, "name", col, sum) where the number of elements or their accumulated total differs from the expected pair — checked inside ProcessElement after iterating values(&i).
Common situations: Beam pipeline tests: a transform emits more/fewer elements than intended, element values changed, or the expected sum passed to passert.Sum is stale.
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
- assert_that must be used within a beam.Pipeline context…
- Failed assert: nothing matches the criterion
- Failed assert: pcol is empty
- %s
- The pipeline contains abandoned PAssert(s).
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/45da99f98711e6a5.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/testing/passert/sum.go:52
grouped := beam.GroupByKey(s, keyed)
beam.ParDo0(s, &sumFn{Name: name, Size: size, Sum: value}, grouped)
}
type sumFn struct {
Name string `json:"name,omitempty"`
Size int `json:"size,omitempty"`
Sum int `json:"sum,omitempty"`
}
func (f *sumFn) ProcessElement(_ int, values func(*int) bool) error {
var sum, count, i int
for values(&i) {
count++
sum += i
}
if f.Sum != sum || f.Size != count {
return errors.Errorf("passert.Sum(%v) = {%v, size: %v}, want {%v, size:%v}", f.Name, sum, count, f.Sum, f.Size)
}
return nil
}
View on GitHub (pinned to 12126d8942)