{"record":{"id":"1cccaa52467d2bd3","repo":"apache/beam","slug":"response-error-sdk-worker","errorCode":null,"errorMessage":"response.error","messagePattern":"response\\.error","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/worker/sdk_worker.py","lineNumber":1155,"sourceCode":"    request.instruction_id = self._context.process_instruction_id\n    # Adding a new item to a dictionary is atomic in cPython\n    self._responses_by_id[request.id] = future = _Future[\n        beam_fn_api_pb2.StateResponse]()\n    # Request queue is thread-safe\n    self._requests.put(request)\n    return future\n\n  def _blocking_request(self, request):\n    # type: (beam_fn_api_pb2.StateRequest) -> beam_fn_api_pb2.StateResponse\n    req_future = self._request(request)\n    while not req_future.wait(timeout=1):\n      if self._exception:\n        raise self._exception\n      elif self._done:\n        raise RuntimeError()\n    response = req_future.get()\n    if response.error:\n      raise RuntimeError(response.error)\n    else:\n      return response\n\n  def _next_id(self):\n    # type: () -> str\n    with self._lock:\n      # Use a lock here because this GrpcStateHandler is shared across all\n      # requests which have the same process bundle descriptor. State requests\n      # can concurrently access this section if a Runner uses threads / workers\n      # (aka \"parallelism\") to send data to this SdkHarness and its workers.\n      self._last_id += 1\n      request_id = self._last_id\n    return str(request_id)\n\n\nclass GlobalCachingStateHandler(CachingStateHandler):\n  \"\"\" A State handler which retrieves and caches state.\n   If caching is activated, caches across bundles using a supplied cache token.","sourceCodeStart":1137,"sourceCodeEnd":1173,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/worker/sdk_worker.py#L1137-L1173","documentation":"When the worker receives a state/request response, the harness propagates any server-side failure by raising RuntimeError(response.error); the raw message 'response.error' in the corpus denotes the generic RuntimeError raised in _blocking_request when a future is done without an exception, or the server-reported error surfaced from the state/request stream.","triggerScenarios":"Calling get_raw (or other BlockingRequest.get) when the RPC response carries an error field, or when the internal request future completes without a result and without an exception recorded.","commonSituations":"State service crashes mid-bundle; gRPC stream terminated by runner; worker-side timeouts cancelling pending requests.","solutions":["Inspect the propagated error text in the exception to find the actual server-side failure","Retry the bundle; transient state-service failures are usually retried by the runner","Check gRPC connectivity between harness and runner (state ApiServiceDescriptor endpoint)","Upgrade Beam; several request-stream race conditions (done-without-exception) were fixed"],"exampleFix":"// before\nresponse = requests.get_raw(request_id).get()\n// after\ntry:\n  response = requests.get_raw(request_id).get()\nexcept RuntimeError as e:\n  _LOGGER.error('state request failed: %s', e)\n  raise","handlingStrategy":"try-catch","validationCode":"if not request_stream.is_active(): raise ConnectionError('state request stream closed')","typeGuard":null,"tryCatchPattern":"try:\n  response = req_future.get()\nexcept RuntimeError as e:\n  log.error('state request failed: %s', e)\n  raise  # runner will retry the bundle","preventionTips":["Monitor gRPC stream health between harness and runner","Retry bundles on transient state-service failures","Keep Beam up to date for request-stream race fixes"],"tags":["apache-beam","grpc","state","rpc"],"backgroundTag":"http-error-response","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}