{"record":{"id":"a74338d9c85bc6f9","repo":"apache/beam","slug":"unknown-state-request-s","errorCode":null,"errorMessage":"Unknown state request: %s","messagePattern":"Unknown state request: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/portability/fn_api_runner/worker_handlers.py","lineNumber":1226,"sourceCode":"      try:\n        request_type = request.WhichOneof('request')\n        if request_type == 'get':\n          data, continuation_token = self._state.get_raw(\n              request.state_key, request.get.continuation_token)\n          yield beam_fn_api_pb2.StateResponse(\n              id=request.id,\n              get=beam_fn_api_pb2.StateGetResponse(\n                  data=data, continuation_token=continuation_token))\n        elif request_type == 'append':\n          self._state.append_raw(request.state_key, request.append.data)\n          yield beam_fn_api_pb2.StateResponse(\n              id=request.id, append=beam_fn_api_pb2.StateAppendResponse())\n        elif request_type == 'clear':\n          self._state.clear(request.state_key)\n          yield beam_fn_api_pb2.StateResponse(\n              id=request.id, clear=beam_fn_api_pb2.StateClearResponse())\n        else:\n          raise NotImplementedError('Unknown state request: %s' % request_type)\n      except Exception as exn:\n        yield beam_fn_api_pb2.StateResponse(id=request.id, error=str(exn))\n\n\nclass SingletonStateHandlerFactory(sdk_worker.StateHandlerFactory):\n  \"\"\"A singleton cache for a StateServicer.\"\"\"\n  def __init__(self, state_handler):\n    # type: (sdk_worker.CachingStateHandler) -> None\n    self._state_handler = state_handler\n\n  def create_state_handler(self, api_service_descriptor):\n    # type: (endpoints_pb2.ApiServiceDescriptor) -> sdk_worker.CachingStateHandler\n\n    \"\"\"Returns the singleton state handler.\"\"\"\n    return self._state_handler\n\n  def close(self):\n    # type: () -> None","sourceCodeStart":1208,"sourceCodeEnd":1244,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/portability/fn_api_runner/worker_handlers.py#L1208-L1244","documentation":"The StateServicer's request loop dispatches on request.WhichOneof('request') values (get/append/clear). Any other request type reaches the else branch and raises NotImplementedError. Notably the surrounding try/except converts this into a StateResponse with an error field rather than crashing the stream.","triggerScenarios":"An SDK harness sends a BeamFnStateRequest whose request oneof is a type this servicer doesn't handle (newer state request kind, or corrupted request) over the state gRPC stream.","commonSituations":"Version mismatch where a newer SDK harness issues state requests an older local job server doesn't implement; custom/generated protobuf stubs out of sync with the runner's proto.","solutions":["Align SDK harness and runner versions so both speak the same BeamFnApi proto revision.","Regenerate/use matching beam_fn_api_pb2 on both sides.","Inspect the StateResponse error payload / logged request_type to identify the unsupported request kind.","If implementing a custom handler, add the request type to the dispatch chain."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"rt = request.WhichOneof('request')\nif rt not in ('get', 'append', 'clear'):\n    skip_request(rt)","typeGuard":"def known_state_request(req): return req.WhichOneof('request') in {'get','append','clear'}","tryCatchPattern":"for resp in stub.State(iter_requests):\n    if resp.error:\n        handle_state_error(resp.error)","preventionTips":["Align protobuf definitions across SDK and runner","Handle error fields in streamed StateResponses","Test state pipelines across version upgrades"],"tags":["state","grpc","version-mismatch","unsupported-feature"],"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"}