{"record":{"id":"68caee433b387aeb","repo":"apache/beam","slug":"bad-windowed-value-v","errorCode":null,"errorMessage":"bad windowed value: %v","messagePattern":"bad windowed value: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/dataflow.go","lineNumber":166,"sourceCode":"\t\trefs, err := EncodeCoderRefs(c.Components)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvalue := refs[1]\n\t\tif len(c.Components) > 2 {\n\t\t\t// TODO(https://github.com/apache/beam/issues/18032): don't inject union coder for CoGBK.\n\n\t\t\tunion := &CoderRef{Type: cogbklistType, Components: refs[1:]}\n\t\t\tvalue = &CoderRef{Type: lengthPrefixType, Components: []*CoderRef{union}}\n\t\t}\n\n\t\tstream := &CoderRef{Type: streamType, Components: []*CoderRef{value}, IsStreamLike: true}\n\t\treturn &CoderRef{Type: pairType, Components: []*CoderRef{refs[0], stream}, IsPairLike: true}, nil\n\n\tcase coder.WindowedValue:\n\t\tif len(c.Components) != 1 || c.Window == nil {\n\t\t\treturn nil, errors.Errorf(\"bad windowed value: %v\", c)\n\t\t}\n\n\t\telm, err := EncodeCoderRef(c.Components[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tw, err := encodeWindowCoder(c.Window)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &CoderRef{Type: windowedValueType, Components: []*CoderRef{elm, w}, IsWrapper: true}, nil\n\n\tcase coder.IW:\n\t\treturn &CoderRef{Type: intervalWindowType}, nil\n\n\tcase coder.Bytes:\n\t\treturn &CoderRef{Type: bytesType}, nil\n","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/dataflow.go#L148-L184","documentation":"EncodeCoderRef encodes coder.WindowedValue coders, which must have exactly one element component and a non-nil Window coder describing the windowing scheme. Anything else cannot be serialized into the runner form, so encoding fails with the coder printed in the message.","triggerScenarios":"Encoding a coder.Coder of Kind coder.WindowedValue where len(c.Components) != 1 or c.Window == nil — e.g. a windowed coder assembled without attaching a window coder.","commonSituations":"Custom windowing code building WindowedValue coders without calling the window-coder constructor (e.g. coder.NewIntervalWindowCoder); global-window pipelines where the window field was cleared; copying coder structs and dropping the unexported/optional Window field.","solutions":["Ensure the WindowedValue coder has exactly one element component and a valid Window coder attached.","Construct windowed coders via the SDK helpers that pair the element coder with the appropriate window coder.","Check custom transforms that replace windowed coders and restore the Window field.","Verify the windowing strategy (fixed/sliding/session/global) is initialized before the graph is serialized."],"exampleFix":"// before\nc := &coder.Coder{Kind: coder.WindowedValue, T: t, Components: []*coder.Coder{elm}} // Window nil\nref, err := graphx.EncodeCoderRef(c)\n\n// after\nc := &coder.Coder{Kind: coder.WindowedValue, T: t, Components: []*coder.Coder{elm}, Window: coder.NewIntervalWindowCoder()}\nref, err := graphx.EncodeCoderRef(c)","handlingStrategy":"validation","validationCode":"func validWindowed(c *coder.Coder) bool {\n\treturn c != nil && c.Kind == coder.WindowedValue && len(c.Components) == 1 && c.Window != nil\n}","typeGuard":"func hasWindow(c *coder.Coder) bool { return c != nil && c.Window != nil }","tryCatchPattern":"ref, err := graphx.EncodeCoderRef(c)\nif err != nil {\n\tif strings.Contains(err.Error(), \"bad windowed value\") {\n\t\treturn fmt.Errorf(\"windowed coder needs 1 element component and a window coder: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Attach the window coder whenever you wrap an element coder as windowed","Never copy Coder structs field-by-field; deep-copy to keep Window","Verify windowing is configured before pipeline submission"],"tags":["go","beam","windowing","coder-serialization"],"backgroundTag":"invalid-argument-value","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"}