apache/beam · error
WriteSimpleRowHeader a 0 length nils bit field: %v
Error message
WriteSimpleRowHeader a 0 length nils bit field: %v
What it means
WriteSimpleRowHeader first encodes the field count as a varint, then writes a varint 0 as the nils bit-field length (simple rows have no nil fields). If the second EncodeVarInt fails, it is wrapped with this message. The odd wording ('a 0 length nils bit field') reflects the wrapped varint-encoding error.
Source
Thrown at sdks/go/pkg/beam/core/graph/coder/row.go:203
// and returns true if the field at that index wasn't encoded
// and can be skipped in decoding.
func IsFieldNil(nils []byte, f int) bool {
i, b := f/8, f%8
// https://github.com/apache/beam/issues/21232: The row header can elide trailing 0 bytes,
// and we shouldn't care if there are trailing 0 bytes when doing a lookup.
return i < len(nils) && len(nils) != 0 && (nils[i]>>uint8(b))&0x1 == 1
}
// WriteSimpleRowHeader is a convenience function to write Beam Schema Row Headers
// for values that do not have any nil fields. Writes the number of fields total
// and a 0 len byte slice to indicate no fields are nil.
func WriteSimpleRowHeader(fields int, w io.Writer) error {
if err := EncodeVarInt(int64(fields), w); err != nil {
return err
}
// Never nils, so we write the 0 byte header.
if err := EncodeVarInt(0, w); err != nil {
return fmt.Errorf("WriteSimpleRowHeader a 0 length nils bit field: %v", err)
}
return nil
}
// ReadSimpleRowHeader is a convenience function to read Beam Schema Row Headers
// for values that do not have any nil fields. Reads and validates the number of
// fields total (returning an error for mismatches, and checks that there are
// no nils encoded as a bit field.
func ReadSimpleRowHeader(fields int, r io.Reader) error {
n, err := DecodeVarInt(r)
if err != nil {
return fmt.Errorf("ReadSimpleRowHeader field count: %v, %v", n, err)
}
if int(n) != fields {
return fmt.Errorf("ReadSimpleRowHeader field count mismatch, got %v, want %v", n, fields)
}
n, err = DecodeVarInt(r)
if err != nil {View on GitHub (pinned to 12126d8942)
Solutions
- Fix the underlying writer error surfaced in the wrapped %v (reopen stream, restore connection).
- Ensure the io.Writer stays open for the whole encode operation.
- If in a runner, let the framework retry the failed bundle.
- Check disk/pipe health when writing serialized rows to files or FIFOs.
Example fix
// before
f, _ := os.OpenFile(path, os.O_WRONLY, 0) // no write permission / wrong flags
coder.WriteSimpleRowHeader(3, f)
// after
f, err := os.Create(path)
if err != nil { return err }
defer f.Close()
coder.WriteSimpleRowHeader(3, f) Defensive patterns
Strategy: try-catch
Validate before calling
if w == nil { return errors.New("nil writer passed to WriteSimpleRowHeader") } Try / catch
if err := coder.WriteSimpleRowHeader(n, w); err != nil {
if errors.Is(err, syscall.EPIPE) { /* reopen stream before retry */ }
return err
} Prevention
- Open output files with write-capable flags and check errors.
- Keep streams open across the whole header+rows write sequence.
- Handle broken pipes on FIFO/network sinks before encoding rows.
When it happens
Trigger: Calling WriteSimpleRowHeader when the underlying io.Writer fails during the second EncodeVarInt — closed stream, broken pipe on the harness data channel, or a failing buffer.
Common situations: Pipeline execution where the writer side of a bundle stream dies mid-header; tests using failing writers; writing to a closed file/pipe.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- error encoding byte: %v
- number of fields is less than byte array %v < %v
- ReadSimpleRowHeader field count: %v, %v
- ReadSimpleRowHeader field count mismatch, got %v, want %v
- varint too long
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/ed5198409f17c02a.
Report an issue: GitHub.