{"record":{"id":"bd63cbfd218aa7ff","repo":"apache/beam","slug":"unknown-state-type","errorCode":null,"errorMessage":"Unknown state type: ","messagePattern":"Unknown state type: ","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/portability/fn_api_runner/worker_handlers.py","lineNumber":1089,"sourceCode":"    yield\n\n  def _get_one_interval_key(self, state_key, start):\n    # type: (beam_fn_api_pb2.StateKey, int) -> bytes\n    state_key_copy = beam_fn_api_pb2.StateKey()\n    state_key_copy.CopyFrom(state_key)\n    state_key_copy.ordered_list_user_state.range.start = start\n    state_key_copy.ordered_list_user_state.range.end = start + 1\n    return self._to_key(state_key_copy)\n\n  def get_raw(\n      self,\n      state_key,  # type: beam_fn_api_pb2.StateKey\n      continuation_token=None  # type: Optional[bytes]\n  ):\n    # type: (...) -> Tuple[bytes, Optional[bytes]]\n\n    if state_key.WhichOneof('type') not in self._SUPPORTED_STATE_TYPES:\n      raise NotImplementedError(\n          'Unknown state type: ' + state_key.WhichOneof('type'))  # type: ignore[operator]\n\n    with self._lock:\n      if not continuation_token:\n        # Compute full_state only when no continuation token is provided.\n        # If there is continuation token, full_state is already in\n        # continuation cache. No need to recompute.\n        full_state = []  # type: List[bytes]\n        if state_key.WhichOneof('type') == 'ordered_list_user_state':\n          maybe_start = state_key.ordered_list_user_state.range.start\n          maybe_end = state_key.ordered_list_user_state.range.end\n          persistent_state_key = beam_fn_api_pb2.StateKey()\n          persistent_state_key.CopyFrom(state_key)\n          persistent_state_key.ordered_list_user_state.ClearField(\"range\")\n\n          available_keys = self._ordered_list_keys[self._to_key(\n              persistent_state_key)]\n","sourceCodeStart":1071,"sourceCodeEnd":1107,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/portability/fn_api_runner/worker_handlers.py#L1071-L1107","documentation":"The StateServicer handling BeamFnState RPCs only supports a fixed set of state_key oneof types (its _SUPPORTED_STATE_TYPES). If a request carries a state key type outside that set, it raises NotImplementedError naming the unknown type. This guards against newer/other state kinds the local servicer cannot serve.","triggerScenarios":"A pipeline using user-state features (e.g. BagState, MultimapState, OrderedListState or a newer state type) whose StateKey oneof is not in _SUPPORTED_STATE_TYPES is executed against a runner using this servicer, via GetState/Append state requests.","commonSituations":"Using stateful DoFn APIs unsupported by the Fn API runner/portable runner combination; SDK newer than runner introducing new state types; cross-version SDK/runner mismatch.","solutions":["Use a state API type supported by the runner (e.g. user BagState/timer types it supports).","Upgrade the runner (or whole Beam) so SDK and runner versions match and support the state type.","Switch to a runner that supports the needed state kind (e.g. Dataflow/Flink) if required.","Check which oneof type is named in the message and consult _SUPPORTED_STATE_TYPES."],"exampleFix":"// before\nstate = ReadModifyWriteStateSpec(...)\n// after (if runner only supports bag state)\nstate = BagStateSpec('state', coders.StrUtf8Coder())","handlingStrategy":"type-guard","validationCode":"if state_key.WhichOneof('type') not in StateServicer._SUPPORTED_STATE_TYPES:\n    raise UnsupportedStateType(state_key.WhichOneof('type'))","typeGuard":"def supported_state(key, supported): return key.WhichOneof('type') in supported","tryCatchPattern":"try:\n    resp = stub.State(iter_requests)\nexcept Exception as e:\n    if 'Unknown state type' in str(e): fall_back_to_supported_state_api()","preventionTips":["Use only state APIs documented for your runner","Keep SDK and runner versions aligned","Check _SUPPORTED_STATE_TYPES before adopting new state kinds"],"tags":["state","grpc","unsupported-feature","version-mismatch"],"backgroundTag":"method-not-implemented","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"}