{"record":{"id":"3d03e59c4139ad20","repo":"apache/beam","slug":"state-type-v-not-recognized-for-state-v","errorCode":null,"errorMessage":"State type %v not recognized for state %v","messagePattern":"State type (.+?) not recognized for state (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/translate.go","lineNumber":617,"sourceCode":"\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tProtocol: &pipepb.FunctionSpec{\n\t\t\t\t\t\t\tUrn: URNMultiMapUserState,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\tcase state.TypeOrderedList:\n\t\t\t\t\tstateSpecs[ps.StateKey()] = &pipepb.StateSpec{\n\t\t\t\t\t\tSpec: &pipepb.StateSpec_OrderedListSpec{\n\t\t\t\t\t\t\tOrderedListSpec: &pipepb.OrderedListStateSpec{\n\t\t\t\t\t\t\t\tElementCoderId: coderID,\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t\tProtocol: &pipepb.FunctionSpec{\n\t\t\t\t\t\t\tUrn: URNOrderedListUserState,\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, errors.Errorf(\"State type %v not recognized for state %v\", ps.StateKey(), ps)\n\t\t\t\t}\n\t\t\t}\n\t\t\tpayload.StateSpecs = stateSpecs\n\t\t}\n\t\tif _, ok := edge.Edge.DoFn.ProcessElementFn().TimerProvider(); ok {\n\t\t\tm.requirements[URNRequiresStatefulProcessing] = true\n\t\t\ttimerSpecs := make(map[string]*pipepb.TimerFamilySpec)\n\t\t\tpipelineTimers, _ := edge.Edge.DoFn.PipelineTimers()\n\n\t\t\t// All timers for a single DoFn have the same key and window coders, that match the input PCollection.\n\t\t\tmainInputID := inputs[\"i0\"]\n\t\t\tpCol := m.pcollections[mainInputID]\n\t\t\tkvCoder := m.coders.coders[pCol.CoderId]\n\t\t\tif kvCoder.GetSpec().GetUrn() != urnKVCoder {\n\t\t\t\treturn nil, errors.Errorf(\"timer using DoFn %v doesn't use a KV as PCollection input. Unable to extract key coder for timers, got %v\", edge.Name, kvCoder.GetSpec().GetUrn())\n\t\t\t}\n\t\t\tkeyCoderID := kvCoder.GetComponentCoderIds()[0]\n","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/translate.go#L599-L635","documentation":"While emitting pipepb.StateSpec entries for a stateful DoFn, addMultiEdge hit a state.ProviderSpec whose StateType is not one of the recognized types (Value, Bag/Map/Set, Combining, OrderedList). The translator throws to avoid generating an invalid StateSpec for the state named in the message.","triggerScenarios":"Marshalling a pipeline whose DoFn uses a custom or newer state type not yet supported by the graphx translator — e.g. a state kind added to the state package but not handled in the switch here.","commonSituations":"SDK version skew where userstate package gained a new state type before translate.go handled it; custom state implementations in embedded runners or tests.","solutions":["Check ps.StateType() against the supported set (Value, Bag, Multimap, Combining, OrderedList)","Upgrade to an SDK version that handles your state type","Switch to a supported state type (e.g. use BagState instead of the unsupported kind)","File a Beam issue if a documented state type is unhandled"],"exampleFix":"// before: custom state type not handled\ntype fn struct { s myCustomState }\n// after: use supported state\nvar _ = state.Value[string, int64](scope, \"s\")","handlingStrategy":"validation","validationCode":"// Reject state types unsupported by the marshaller before building the pipeline\nallowed := map[state.Type]bool{state.TypeValue: true, state.TypeBag: true, state.TypeMultimap: true, state.TypeCombining: true, state.TypeOrderedList: true}\nif !allowed[ps.StateType()] {\n    return fmt.Errorf(\"state %q uses unsupported type %v\", ps.StateKey(), ps.StateType())\n}","typeGuard":"func isSupportedStateType(t state.Type) bool {\n    switch t {\n    case state.TypeValue, state.TypeBag, state.TypeMultimap, state.TypeCombining, state.TypeOrderedList:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if _, err := graphx.Marshal(p); err != nil {\n    if strings.Contains(err.Error(), \"State type\") && strings.Contains(err.Error(), \"not recognized\") {\n        return fmt.Errorf(\"upgrade SDK or change state type: %v\", err)\n    }\n    return err\n}","preventionTips":["Use only documented state types from the state package","Keep userstate and graphx versions from the same SDK release","Check Beam release notes for new state kinds before adopting them"],"tags":["go","apache-beam","state","unsupported-type"],"backgroundTag":"invalid-enum-value","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"}