apache/beam · error

retrieving time data: %v

Error message

retrieving time data: %v

What it means

In the time.Time schema override decoder (sdks/go/pkg/beam/encoding.go), the raw time bytes are extracted with coder.DecodeBytes after the row header. If that length-prefixed byte read fails (truncated stream, bad length prefix), the error is wrapped as "retrieving time data". This means the payload bytes of the encoded time.Time could not be read from the stream.

Source

Thrown at sdks/go/pkg/beam/encoding.go:292

		data, err := t.MarshalText()
		if err != nil {
			return fmt.Errorf("marshalling time: %v", err)
		}
		if err := coder.EncodeBytes(data, w); err != nil {
			return err
		}
		return nil
	}, nil
}

func timeDec(reflect.Type) (func(io.Reader) (any, error), error) {
	return func(r io.Reader) (any, error) {
		if err := coder.ReadSimpleRowHeader(1, r); err != nil {
			return nil, errors.Wrap(err, "decoding time.Time schema override")
		}
		data, err := coder.DecodeBytes(r)
		if err != nil {
			return nil, errors.Wrap(err, "retrieving time data: %v")
		}
		t := time.Time{}
		if err := t.UnmarshalText(data); err != nil {
			return nil, errors.Wrap(err, "decoding time: %v")
		}
		return t, nil
	}, nil
}

View on GitHub (pinned to 12126d8942)

Solutions

  1. Re-encode the data with the current Beam SDK version.
  2. Check the wrapped error for truncation (unexpected EOF) and inspect the record length prefix.
  3. Validate record integrity upstream (checksums, complete writes) before decoding.
  4. Fall back to decoding with time.Time.UnmarshalText directly if the data is known to be plain RFC3339 text.

Example fix

// before: blind decode
v, _ := decodeRecord(raw)
// after: guard completeness first
if len(raw) < 2 { return nil, fmt.Errorf("record too short for encoded time") }
v, err := decodeRecord(raw)
if err != nil { return nil, fmt.Errorf("corrupt time record: %w", err) }
Defensive patterns

Strategy: validation

Validate before calling

if len(raw) < 2 { // header + length prefix sanity
    return fmt.Errorf("payload too short for encoded time.Time")
}

Prevention

When it happens

Trigger: Decoding a schema-encoded time.Time whose length prefix claims more bytes than remain in the stream, or a corrupted length prefix.

Common situations: Truncated files/records, data written by a different Beam version with a different bytes encoding, or network/stream interruption mid-record.

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


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