{"record":{"id":"2a93f85e6de96014","repo":"apache/beam","slug":"error-decoding-bool-received-invalid-value-v","errorCode":null,"errorMessage":"error decoding bool: received invalid value %v","messagePattern":"error decoding bool: received invalid value (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/coder.go","lineNumber":373,"sourceCode":"\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\n}\n\ntype varIntEncoder struct{}\n\nfunc (*varIntEncoder) Encode(val *FullValue, w io.Writer) error {\n\t// Encoding: beam varint\n\treturn coder.EncodeVarInt(val.Elm.(int64), w)\n}\n\ntype varIntDecoder struct{}","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/coder.go#L355-L391","documentation":"This error comes from the Beam Go SDK's boolDecoder in exec/coder.go. During decoding of a wire-encoded boolean, the decoder found a byte that is neither 0 nor 1, so it cannot reconstruct a bool FullValue. It indicates corrupt or non-conforming encoded data rather than user-facing API misuse.","triggerScenarios":"Calling Decode/DecodeTo on a stream whose underlying bytes were produced with a different coder, truncated mid-element, or manually crafted so the bool byte is not 0 or 1.","commonSituations":"Corrupted pipeline artifacts or state caches, mismatched coder versions between job submitter and worker, manually edited captured streams, or reading a stream offset into the middle of an element.","solutions":["Verify the coder registry and coder IDs match between pipeline construction and the worker runtime (same Beam SDK version).","Re-generate or clear any cached/serialized data (state caches, test fixtures) that may be corrupted.","Check that stream offsets and reader boundaries are aligned to element boundaries; a partial read yields invalid bytes.","Log the raw byte value (%v) to identify what is actually being read and trace where the stream diverged."],"exampleFix":"// before: decoding raw bytes with mismatched coder\ndec := exec.MakeElementDecoder(badCoder)\nfv, err := dec.Decode(r)\n// after: ensure coder comes from the same model pipeline / registry\ndec := exec.MakeElementDecoder(coder.FromProto(modelPipelineComponents))\nfv, err := dec.Decode(r)\nif err != nil {\n    return fmt.Errorf(\"bool decode failed, check coder consistency: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"if b != 0 && b != 1 { return fmt.Errorf(\"invalid bool byte %d before decode\", b) }","typeGuard":"func isValidBoolByte(b byte) bool { return b == 0 || b == 1 }","tryCatchPattern":"fv, err := dec.Decode(r)\nif err != nil {\n    if strings.Contains(err.Error(), \"error decoding bool\") {\n        return fmt.Errorf(\"corrupt stream or coder mismatch: %w\", err)\n    }\n    return err\n}","preventionTips":["Pin the same Beam SDK version for pipeline submission and workers","Never hand-edit encoded element bytes or test fixtures","Keep reader offsets aligned to element boundaries"],"tags":["decoding","beam-go","data-corruption","coder"],"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-20T03:17:13.778Z"}