apache/beam · error
passert.Hash( ) = ( , ), want ( , )
Error message
passert.Hash(%v) = (%v,%v), want (%v,%v)
What it means
passert.Hash asserts both the size and the base64-encoded MD5 hash of a PCollection's concatenated element bytes. errFn.ProcessElement fails with 'passert.Hash(%v) = (%v,%v), want (%v,%v)' when either the observed length or hash differs from the expectation.
Solutions
- Compare the observed (size, hash) in the message with expected to see whether content or length changed.
- If the change is intentional, recompute and update the expected hash/size in the test.
- Make element ordering deterministic (sort before hashing) if order varies.
- Check for coder changes that alter serialized bytes.
Example fix
// before passert.Hash(s, col, "c29832...", 42) // after // recompute expected hash after a legitimate data/coder change: passert.Hash(s, col, "9f86d0...", 42)
Defensive patterns
Strategy: try-catch
Validate before calling
h := md5.Sum(serializedBytes)
want := base64.StdEncoding.EncodeToString(h[:])
if want != expectedHash {
t.Fatalf("expected hash stale: have %s want %s", want, expectedHash)
} Try / catch
if err := beamx.Execute(ctx, p); err != nil {
if strings.Contains(err.Error(), "passert.Hash") {
// diff observed (len,hash) vs expected; recompute expectation if change is intentional
}
} Prevention
- Recompute expected hashes whenever coders or data change.
- Sort elements before hashing if order is nondeterministic.
- Pin library versions in test environments to avoid coder drift.
When it happens
Trigger: The serialized element bytes differ from what the expectation was computed against — element values, ordering, or the coder changed, altering len(col) or the MD5 digest.
Common situations: Coder or serialization format changed between library versions; nondeterministic element order; upstream data or transforms modified content.
Understand the failure class
Background: Checksum mismatch errors: "checksum verification failed", "digest mismatch", "expected vs actual checksum" — what they mean and how to fix them — this error's family across 41 libraries.
Related errors
- missing entries (missing in actual, present in expected)
- observed PCollection has incompatible type
- passert.Count( ) = , want
- passert.Diff input PColections don't have matching types
- PCollections of different lengths, got
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/5f4b6ece47e9baf0.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/testing/passert/hash.go:63
func (f *hashFn) ProcessElement(_ int, lines func(*string) bool) error {
var col []string
var str string
for lines(&str) {
col = append(col, str)
}
sort.Strings(col)
md5W := md5.New()
for _, str := range col {
if _, err := md5W.Write([]byte(str)); err != nil {
panic(err) // cannot fail
}
}
hash := base64.StdEncoding.EncodeToString(md5W.Sum(nil))
if f.Size != len(col) || f.Hash != hash {
return errors.Errorf("passert.Hash(%v) = (%v,%v), want (%v,%v)", f.Name, len(col), hash, f.Size, f.Hash)
}
return nil
}
View on GitHub (pinned to 12126d8942)