{"record":{"id":"6c047c845d00e8d2","repo":"apache/beam","slug":"decoding-time-time-schema-override","errorCode":null,"errorMessage":"decoding time.Time schema override","messagePattern":"decoding time\\.Time schema override","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/encoding.go","lineNumber":288,"sourceCode":"\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) {\n\t\tif err := coder.ReadSimpleRowHeader(1, r); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"decoding time.Time schema override\")\n\t\t}\n\t\tdata, err := coder.DecodeBytes(r)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"retrieving time data: %v\")\n\t\t}\n\t\tt := time.Time{}\n\t\tif err := t.UnmarshalText(data); err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"decoding time: %v\")\n\t\t}\n\t\treturn t, nil\n\t}, nil\n}\n","sourceCodeStart":270,"sourceCodeEnd":301,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/encoding.go#L270-L301","documentation":"This error wraps a failure to read the 1-field Beam schema row header while decoding a time.Time value using the Beam schema override registered in sdks/go/pkg/beam/encoding.go. The timeDec override reads a simple row header before the encoded time bytes; if the stream does not begin with the expected header, the read fails and the underlying error is wrapped with this message. It indicates the byte stream being decoded is not a valid schema-encoded time.Time.","triggerScenarios":"Calling beam decoding (e.g. via schema encoding/decoding of a pipeline element) on a byte stream containing a time.Time field where the data is corrupt, truncated, or was not produced by the matching timeEnc override.","commonSituations":"Corrupt or hand-crafted encoded blobs, mixed Beam SDK versions where the row-header format changed, or decoding data written by a custom encoder that skips ReadSimpleRowHeader.","solutions":["Regenerate the encoded data with the same Beam version (re-run the encoding side of the pipeline).","Verify the stream is decoded with the registered schema override for time.Time, not a generic decoder.","Inspect the wrapped underlying error (via errors.Wrap chain) to see whether it is EOF/truncation versus a header mismatch.","If using custom serialization, ensure bytes are produced with coder.WriteSimpleRowHeader(1) followed by coder.EncodeBytes."],"exampleFix":"// before: decoding arbitrary bytes as time.Time\nv, err := decodeAsBytes(raw)\n// after: ensure data was encoded by the beam time.Time override\nif len(raw) < 1 { return fmt.Errorf(\"empty payload for time.Time\") }\nt, err := decodeTimeOverride(raw) // uses ReadSimpleRowHeader + DecodeBytes","handlingStrategy":"try-catch","validationCode":"if len(raw) == 0 {\n    return fmt.Errorf(\"empty payload: cannot decode time.Time override\")\n}","typeGuard":null,"tryCatchPattern":"if err := decodeTime(raw); err != nil {\n    if strings.Contains(err.Error(), \"decoding time.Time schema override\") {\n        return fmt.Errorf(\"corrupt time.Time payload: %w\", err)\n    }\n    return err\n}","preventionTips":["Always encode time.Time through the registered Beam schema override","Keep Beam SDK versions consistent between encoder and decoder","Never hand-craft schema-encoded records"],"tags":["beam","decoding","schema","serialization"],"backgroundTag":"schema-validation-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}