apache/beam · error · RuntimeError

response.error

Error message

response.error

What it means

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.

Source

Thrown at sdks/python/apache_beam/runners/worker/sdk_worker.py:1155

    request.instruction_id = self._context.process_instruction_id
    # Adding a new item to a dictionary is atomic in cPython
    self._responses_by_id[request.id] = future = _Future[
        beam_fn_api_pb2.StateResponse]()
    # Request queue is thread-safe
    self._requests.put(request)
    return future

  def _blocking_request(self, request):
    # type: (beam_fn_api_pb2.StateRequest) -> beam_fn_api_pb2.StateResponse
    req_future = self._request(request)
    while not req_future.wait(timeout=1):
      if self._exception:
        raise self._exception
      elif self._done:
        raise RuntimeError()
    response = req_future.get()
    if response.error:
      raise RuntimeError(response.error)
    else:
      return response

  def _next_id(self):
    # type: () -> str
    with self._lock:
      # Use a lock here because this GrpcStateHandler is shared across all
      # requests which have the same process bundle descriptor. State requests
      # can concurrently access this section if a Runner uses threads / workers
      # (aka "parallelism") to send data to this SdkHarness and its workers.
      self._last_id += 1
      request_id = self._last_id
    return str(request_id)


class GlobalCachingStateHandler(CachingStateHandler):
  """ A State handler which retrieves and caches state.
   If caching is activated, caches across bundles using a supplied cache token.

View on GitHub (pinned to 12126d8942)

Solutions

  1. Inspect the propagated error text in the exception to find the actual server-side failure
  2. Retry the bundle; transient state-service failures are usually retried by the runner
  3. Check gRPC connectivity between harness and runner (state ApiServiceDescriptor endpoint)
  4. Upgrade Beam; several request-stream race conditions (done-without-exception) were fixed

Example fix

// before
response = requests.get_raw(request_id).get()
// after
try:
  response = requests.get_raw(request_id).get()
except RuntimeError as e:
  _LOGGER.error('state request failed: %s', e)
  raise
Defensive patterns

Strategy: try-catch

Validate before calling

if not request_stream.is_active(): raise ConnectionError('state request stream closed')

Try / catch

try:
  response = req_future.get()
except RuntimeError as e:
  log.error('state request failed: %s', e)
  raise  # runner will retry the bundle

Prevention

When it happens

Trigger: 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.

Common situations: State service crashes mid-bundle; gRPC stream terminated by runner; worker-side timeouts cancelling pending requests.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/1cccaa52467d2bd3. Report an issue: GitHub.