{"record":{"id":"ea71aa6f3b45783f","repo":"apache/beam","slug":"encoding-time-time-schema-override","errorCode":null,"errorMessage":"encoding time.Time schema override","messagePattern":"encoding time\\.Time schema override","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/encoding.go","lineNumber":268,"sourceCode":"\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\ts, err := coder.DecodeStringUTF8(r)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tc, err := graphx.DecodeCoder(s)\n\t\t\tif err != nil {\n\t\t\t\treturn EncodedCoder{}, err\n\t\t\t}\n\t\t\treturn EncodedCoder{Coder: Coder{coder: c}}, nil\n\t\t},\n\t\tnil\n}\n\nfunc timeEnc(reflect.Type) (func(any, io.Writer) error, error) {\n\treturn func(iface any, w io.Writer) error {\n\t\tif err := coder.WriteSimpleRowHeader(1, w); err != nil {\n\t\t\treturn errors.Wrap(err, \"encoding time.Time schema override\")\n\t\t}\n\t\tt := iface.(time.Time)\n\t\t// We use the text marshalling rather than the binary marshalling\n\t\t// since it has more precision. Apparently some info isn't included\n\t\t// in the binary marshal.\n\t\tdata, err := t.MarshalText()\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"marshalling time: %v\", err)\n\t\t}\n\t\tif err := coder.EncodeBytes(data, w); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn nil\n\t}, nil\n}\n\nfunc timeDec(reflect.Type) (func(io.Reader) (any, error), error) {\n\treturn func(r io.Reader) (any, error) {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/encoding.go#L250-L286","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nf, _ := os.Create(path)\nenc := schemax.NewRowEncoderForType(reflect.TypeOf(time.Time{}))\nenc.Encode(t, f)\nf.Close() // closed before later Encode calls fail\n// after\nf, _ := os.Create(path)\ndefer f.Close() // keep writer open until encoding completes\nenc.Encode(t, f)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := enc.Encode(t, w); err != nil {\n    return fmt.Errorf(\"time.Time schema encode failed: %w\", err) // inner error names the writer failure\n}","preventionTips":["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"],"tags":["beam","schema-coder","io"],"backgroundTag":"serialization-failed","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"}