{"record":{"id":"a57c919723b05be1","repo":"apache/beam","slug":"invalid-number-of-components-for-windowedvalue","errorCode":null,"errorMessage":"Invalid number of components for WindowedValue","messagePattern":"Invalid number of components for WindowedValue","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/typex/fulltype.go","lineNumber":135,"sourceCode":"\t\t\t}\n\t\t\t// For elements which themselves have components, we need to go deeper.\n\t\t\treturn &tree{class, t, []FullType{New(t.Elem(), components[0].Components()...)}}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"Unexpected aggregate type: %v\", t))\n\t\t}\n\tcase Composite:\n\t\tswitch t {\n\t\tcase KVType:\n\t\t\tif len(components) != 2 {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid number of components for KV: %v, %v\", t, components))\n\t\t\t}\n\t\t\tif isAnyNonKVAndNonWindowedComposite(components) {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid to nest composite composites inside KV: %v, %v\", t, components))\n\t\t\t}\n\t\t\treturn &tree{class, t, components}\n\t\tcase WindowedValueType:\n\t\t\tif len(components) != 1 {\n\t\t\t\tpanic(\"Invalid number of components for WindowedValue\")\n\t\t\t}\n\t\t\tif components[0].Type() == WindowedValueType {\n\t\t\t\tpanic(\"Invalid to nest WindowedValue\")\n\t\t\t}\n\t\t\treturn &tree{class, t, components}\n\t\tcase CoGBKType:\n\t\t\tif len(components) < 2 {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid number of components for CoGBK: %v\", t))\n\t\t\t}\n\t\t\tif isAnyNonKVComposite(components) {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid to nest composites inside CoGBK: %v\", t))\n\t\t\t}\n\t\t\treturn &tree{class, t, components}\n\t\tcase TimersType:\n\t\t\treturn &tree{class, t, components}\n\t\tcase ShardedKeyType:\n\t\t\tif len(components) != 1 {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid number of components for ShardedKey: %v, %v\", t, components))","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/typex/fulltype.go#L117-L153","documentation":"FullType.New requires exactly one component for a WindowedValue composite; any other count panics. WindowedValue wraps exactly one element FullType plus window metadata handled internally, so a different component count is an invalid construction.","triggerScenarios":"Calling typex.New with WindowedValueType and a components slice whose length is not 1 — usually from hand-assembled component lists in custom graph construction.","commonSituations":"Custom windowing code building WindowedValue FullTypes manually; codegen tools emitting extra components (e.g. including window/timestamp as components).","solutions":["Pass exactly one component (the element FullType) when constructing a WindowedValue type.","Use beam.WindowInto and the SDK's windowing APIs instead of building WindowedValue types manually.","Validate the component list length before calling typex.New."],"exampleFix":"// before\ntypex.New(typex.WindowedValueType, elemFT, windowFT) // 2 components: panics\n// after\ntypex.New(typex.WindowedValueType, elemFT)","handlingStrategy":"validation","validationCode":"if t == typex.WindowedValueType && len(components) != 1 {\n\treturn fmt.Errorf(\"WindowedValue requires exactly 1 component, got %d\", len(components))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass only the element FullType as the WindowedValue component.","Use beam.WindowInto rather than constructing WindowedValue types manually."],"tags":["go","beam","typex","windowed-value","panic"],"backgroundTag":"missing-required-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}