{"record":{"id":"855ad6909d1701c7","repo":"apache/beam","slug":"readsimplerowheader-field-count-v-v","errorCode":null,"errorMessage":"ReadSimpleRowHeader field count: %v, %v","messagePattern":"ReadSimpleRowHeader field count: (.+?), (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/coder/row.go","lineNumber":215,"sourceCode":"func WriteSimpleRowHeader(fields int, w io.Writer) error {\n\tif err := EncodeVarInt(int64(fields), w); err != nil {\n\t\treturn err\n\t}\n\t// Never nils, so we write the 0 byte header.\n\tif err := EncodeVarInt(0, w); err != nil {\n\t\treturn fmt.Errorf(\"WriteSimpleRowHeader a 0 length nils bit field: %v\", err)\n\t}\n\treturn nil\n}\n\n// ReadSimpleRowHeader is a convenience function to read Beam Schema Row Headers\n// for values that do not have any nil fields. Reads and validates the number of\n// fields total (returning an error for mismatches, and checks that there are\n// no nils encoded as a bit field.\nfunc ReadSimpleRowHeader(fields int, r io.Reader) error {\n\tn, err := DecodeVarInt(r)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"ReadSimpleRowHeader field count: %v, %v\", n, err)\n\t}\n\tif int(n) != fields {\n\t\treturn fmt.Errorf(\"ReadSimpleRowHeader field count mismatch, got %v, want %v\", n, fields)\n\t}\n\tn, err = DecodeVarInt(r)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"ReadSimpleRowHeader reading nils count: %v, %v\", n, err)\n\t}\n\tif n != 0 {\n\t\treturn fmt.Errorf(\"ReadSimpleRowHeader expected no nils encoded count, got %v\", n)\n\t}\n\treturn nil\n}\n","sourceCodeStart":197,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/coder/row.go#L197-L229","documentation":"ReadSimpleRowHeader decodes a simple row header (field count plus a 0-length nils field). This error wraps a failure of the first DecodeVarInt reading the field count; n is included (usually 0) along with the underlying read error. The stream ended early, contains corrupt bytes, or is not a simple row header at all.","triggerScenarios":"Calling ReadSimpleRowHeader on an empty/exhausted reader, on truncated data, or on data whose leading bytes are not a valid varint.","commonSituations":"Reading a serialized row file that was truncated; decoding from a closed gRPC stream; accidental use of ReadSimpleRowHeader on data written with a different header format.","solutions":["Check the wrapped read error: io.EOF means truncated/empty input — verify the data source is complete.","Ensure the reader is positioned at the start of a row header (don't consume bytes beforehand).","Re-generate or re-export the data if the file/stream is corrupt.","Confirm the writer used WriteSimpleRowHeader so formats match."],"exampleFix":"// before\ndata := truncatedBytes[:5]\ncoder.ReadSimpleRowHeader(3, bytes.NewReader(data)) // EOF\n// after\nif len(data) < 2 { return io.ErrUnexpectedEOF }\ncoder.ReadSimpleRowHeader(3, bytes.NewReader(fullBytes))","handlingStrategy":"validation","validationCode":"if r == nil { return errors.New(\"nil reader\") }\nif b, ok := r.(*bytes.Reader); ok && b.Len() < 2 { return io.ErrUnexpectedEOF }","typeGuard":null,"tryCatchPattern":"err := coder.ReadSimpleRowHeader(fields, r)\nif err != nil && strings.Contains(err.Error(), \"ReadSimpleRowHeader field count:\") {\n\tif errors.Is(err, io.EOF) { return io.ErrUnexpectedEOF }\n\treturn err\n}","preventionTips":["Validate input completeness (file size/stream length) before decoding headers.","Don't consume reader bytes before calling ReadSimpleRowHeader.","Match the reader to data written by WriteSimpleRowHeader only."],"tags":["go","beam","serialization","row-coder","corruption"],"backgroundTag":"unexpected-response-shape","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}