apache/beam · error
encoding time.Time schema override
Error message
encoding time.Time schema override
What it means
timeEnc is the schema-override encoder for time.Time values. This error wraps a failure writing the simple row header (a one-field row marker) that must precede the time.Time payload in the Beam schema encoding.
Solutions
- Inspect the wrapped inner error to identify the underlying writer failure
- Ensure the destination writer stays open until all elements are encoded
- Check disk space / connection health for file or network-backed writers
Example fix
// before
f, _ := os.Create(path)
enc := schemax.NewRowEncoderForType(reflect.TypeOf(time.Time{}))
enc.Encode(t, f)
f.Close() // closed before later Encode calls fail
// after
f, _ := os.Create(path)
defer f.Close() // keep writer open until encoding completes
enc.Encode(t, f) Defensive patterns
Strategy: try-catch
Try / catch
if err := enc.Encode(t, w); err != nil {
return fmt.Errorf("time.Time schema encode failed: %w", err) // inner error names the writer failure
} Prevention
- Keep destination writers open until all encoding completes; use defer Close
- Inspect the wrapped inner error to locate the true writer failure
- Handle broken pipes / closed streams from inter-process coder channels explicitly
When it happens
Trigger: The io.Writer passed to the encoder fails during coder.WriteSimpleRowHeader — e.g. the writer is closed, the underlying buffer/pipe is broken, or a disk/network write error occurs mid-encode.
Common situations: Writing schema-encoded time.Time columns to a closed output stream, failed file sinks, or broken pipes when streaming encoded rows over a channel between pipeline processes.
Related errors
- Caller does not own the underlying input stream and should…
- Caller does not own the underlying input stream and should…
- Can not get unique key from solr
- Delimiter must be a non-empty bytes sequence.
- Delimiter must not self-overlap.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/ea71aa6f3b45783f.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/encoding.go:268
return nil, err
}
s, err := coder.DecodeStringUTF8(r)
if err != nil {
return nil, err
}
c, err := graphx.DecodeCoder(s)
if err != nil {
return EncodedCoder{}, err
}
return EncodedCoder{Coder: Coder{coder: c}}, nil
},
nil
}
func timeEnc(reflect.Type) (func(any, io.Writer) error, error) {
return func(iface any, w io.Writer) error {
if err := coder.WriteSimpleRowHeader(1, w); err != nil {
return errors.Wrap(err, "encoding time.Time schema override")
}
t := iface.(time.Time)
// We use the text marshalling rather than the binary marshalling
// since it has more precision. Apparently some info isn't included
// in the binary marshal.
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) {View on GitHub (pinned to 12126d8942)