{"record":{"id":"fc908181a294b297","repo":"apache/beam","slug":"request-to-s-failed-with-status-d-s","errorCode":null,"errorMessage":"Request to %s failed with status %d: %s","messagePattern":"Request to (.+?) failed with status (.+?): (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/portability/flink_uber_jar_job_server.py","lineNumber":134,"sourceCode":"      job_id,\n      job_name,\n      pipeline,\n      options,\n      artifact_port=0):\n    super().__init__(\n        executable_jar,\n        job_id,\n        job_name,\n        pipeline,\n        options,\n        artifact_port=artifact_port)\n    self._master_url = master_url\n\n  def request(self, method, path, expected_status=200, **kwargs):\n    url = '%s/%s' % (self._master_url, path)\n    response = method(url, **kwargs)\n    if response.status_code != expected_status:\n      raise RuntimeError(\n          \"Request to %s failed with status %d: %s\" %\n          (url, response.status_code, response.text))\n    if response.text:\n      return response.json()\n\n  def get(self, path, **kwargs):\n    return self.request(requests.get, path, **kwargs)\n\n  def post(self, path, **kwargs):\n    return self.request(requests.post, path, **kwargs)\n\n  def delete(self, path, **kwargs):\n    return self.request(requests.delete, path, **kwargs)\n\n  def run(self):\n    self._stop_artifact_service()\n\n    # Upload the jar and start the job.","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/portability/flink_uber_jar_job_server.py#L116-L152","documentation":"FlinkRestServer.request wraps all Flink master REST calls (get/post/delete). When the response status differs from expected (default 200), it raises RuntimeError with the URL, actual status code, and response body — the Flink cluster rejected or failed to serve the request.","triggerScenarios":"Any REST call through get/post/delete returning a non-expected status: uploading jars when upload is restricted, deleting/getting an unknown job or jar id, cluster error states, or proxies returning 403/404/500 pages.","commonSituations":"Wrong --flink_master endpoint; job/jar already terminated or cleaned up; Flink REST API disabled or version mismatch; reverse proxy/auth intercepting requests.","solutions":["Read the status code and body in the RuntimeError to identify the cause (404 = not found, 403 = denied, 500 = cluster error).","Verify master_url / --flink_master points at the correct, reachable JobManager REST endpoint.","Confirm the requested job_id/jar id still exists (GET /jobs or /jars) before mutating calls.","Retry on transient 5xx or restart the Flink cluster if errors persist."],"exampleFix":"// before\nclient.post('jars/upload', files=...)  # RuntimeError status 403\n// after\n# fix flink-conf REST/auth settings, then:\nresp = client.post('jars/upload', files=...)\nassert resp['status'] == 'success'","handlingStrategy":"retry","validationCode":"import requests\nok = requests.get(f'{master_url}/overview', timeout=5).status_code == 200\nassert ok, f\"Flink master unreachable: {master_url}\"","typeGuard":null,"tryCatchPattern":"from tenacity import retry, stop_after_attempt, wait_exponential\n\n@retry(stop=stop_after_attempt(3), wait=wait_exponential())\ndef safe_get(client, path):\n    try:\n        return client.get(path)\n    except RuntimeError as e:\n        if 'status 404' in str(e):\n            raise  # not retryable: entity missing\n        raise  # or retry transient 5xx per policy","preventionTips":["Verify --flink_master points at a live JobManager REST endpoint before submitting.","Check job/jar ids exist via GET /jobs or /jars before delete/run calls.","Retry transient 5xx with backoff; treat 404/403 as configuration problems.","Confirm Flink's REST API is enabled and reachable through any proxy."],"tags":["python","apache-beam","flink","http","rest"],"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"}