{"record":{"id":"52b0a6a16c702869","repo":"apache/beam","slug":"error-decoding-bool-v","errorCode":null,"errorMessage":"error decoding bool: %v","messagePattern":"error decoding bool: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/coder.go","lineNumber":363,"sourceCode":"\t} else {\n\t\t_, err = ioutilx.WriteUnsafe(w, []byte{0})\n\t}\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error encoding bool: %v\", err)\n\t}\n\treturn nil\n}\n\ntype boolDecoder struct{}\n\nfunc (*boolDecoder) DecodeTo(r io.Reader, fv *FullValue) error {\n\t// Encoding: false = 0, true = 1\n\tb := make([]byte, 1)\n\tif err := ioutilx.ReadNBufUnsafe(r, b); err != nil {\n\t\tif err == io.EOF {\n\t\t\treturn err\n\t\t}\n\t\treturn fmt.Errorf(\"error decoding bool: %v\", err)\n\t}\n\tswitch b[0] {\n\tcase 0:\n\t\t*fv = FullValue{Elm: false}\n\t\treturn nil\n\tcase 1:\n\t\t*fv = FullValue{Elm: true}\n\t\treturn nil\n\t}\n\treturn fmt.Errorf(\"error decoding bool: received invalid value %v\", b)\n}\n\nfunc (d *boolDecoder) Decode(r io.Reader) (*FullValue, error) {\n\tfv := &FullValue{}\n\tif err := d.DecodeTo(r, fv); err != nil {\n\t\treturn nil, err\n\t}\n\treturn fv, nil","sourceCodeStart":345,"sourceCodeEnd":381,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/coder.go#L345-L381","documentation":"The exec coder's DecodeTo reads a single byte to decode a bool (0=false, 1=true). Any read error other than clean io.EOF is wrapped as 'error decoding bool'. io.EOF is passed through unchanged to signal a legitimate end of stream.","triggerScenarios":"Decoding a bool from a stream where the read fails mid-byte: connection reset, corrupted reader, or an I/O error other than EOF. A clean EOF (no bytes at all) returns io.EOF instead.","commonSituations":"Truncated data channel between pipeline stages; reading past a partially written record so a partial read error surfaces; broken network transport during shuffle.","solutions":["Distinguish io.EOF (expected end of stream) from the wrapped error (real corruption/IO failure) with errors.Is.","Verify the encoder wrote complete records; a truncated record often precedes this error.","Check transport health (network, pipes) between the writing and reading stages.","Regenerate or re-fetch the corrupted input data."],"exampleFix":"// before: treating all errors the same\nerr := dec.DecodeTo(r, fv)\n// after: distinguish EOF from corruption\nif err := dec.DecodeTo(r, fv); err != nil && !errors.Is(err, io.EOF) {\n    return fmt.Errorf(\"record corrupted: %w\", errors.Unwrap(err))\n}","handlingStrategy":"try-catch","validationCode":"// Frame records with lengths so readers never do partial reads mid-bool.","typeGuard":"func isEOF(err error) bool { return errors.Is(err, io.EOF) }","tryCatchPattern":"err := dec.DecodeTo(r, fv)\nif err != nil {\n    if errors.Is(err, io.EOF) { return io.EOF }\n    if strings.Contains(err.Error(), \"error decoding bool\") { return ErrCorruptRecord }\n    return err\n}","preventionTips":["Distinguish io.EOF from wrapped read errors with errors.Is","Length-prefix records to detect truncation early","Monitor transport health between pipeline stages"],"tags":["go","apache-beam","decoding","io","bool"],"backgroundTag":"file-read-failed","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"}