apache/beam · error

error decoding varint field

Error message

error decoding varint field

What it means

Wrap added by reflectDecodeInt in the reflective row decoder when DecodeVarInt fails. The Beam wire format encodes int fields as varints; this error means the reader hit EOF or garbage while decoding such a field, i.e. the row bytes are truncated or were produced with an incompatible coder.

Solutions

  1. Verify data completeness and that it was written by a compatible Beam encoder.
  2. Re-encode the input data.
  3. Align reader/writer schemas so field positions match.
  4. Check for varint corruption at the failing offset.
Defensive patterns

Strategy: try-catch

Try / catch

if err := decoderFn(rv, r); err != nil {
    if strings.Contains(err.Error(), "error decoding varint field") {
        return fmt.Errorf("malformed or truncated varint in int field: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: reflectDecodeInt during row decoding when DecodeVarInt hits EOF or encounters a malformed varint — truncated input or misaligned decode of foreign data.

Common situations: Truncated Beam-encoded blobs, cross-version coder mismatch, decoding data written by other frameworks into Beam row coders.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/c997f1364a0e91f4. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/graph/coder/row_decoder.go:229

		return errors.Wrap(err, "error decoding single byte field")
	}
	rv.SetUint(uint64(b))
	return nil
}

func reflectDecodeString(rv reflect.Value, r io.Reader) error {
	v, err := DecodeStringUTF8(r)
	if err != nil {
		return errors.Wrap(err, "error decoding string field")
	}
	rv.SetString(v)
	return nil
}

func reflectDecodeInt(rv reflect.Value, r io.Reader) error {
	v, err := DecodeVarInt(r)
	if err != nil {
		return errors.Wrap(err, "error decoding varint field")
	}
	rv.SetInt(v)
	return nil
}

func reflectDecodeUint(rv reflect.Value, r io.Reader) error {
	v, err := DecodeVarUint64(r)
	if err != nil {
		return errors.Wrap(err, "error decoding varint field")
	}
	rv.SetUint(v)
	return nil
}

func reflectDecodeSinglePrecisionFloat(rv reflect.Value, r io.Reader) error {
	v, err := DecodeSinglePrecisionFloat(r)
	if err != nil {
		return errors.Wrap(err, "error decoding single-precision float field")

View on GitHub (pinned to 12126d8942)