{"record":{"id":"398b0042b0afbf04","repo":"apache/beam","slug":"job-does-not-exist-local-service","errorCode":null,"errorMessage":"Job {} does not exist","messagePattern":"Job (.+?) does not exist","errorType":"exception","errorClass":"LookupError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/portability/local_job_service.py","lineNumber":156,"sourceCode":"        '%s:%d' % (self.get_bind_address(), port))\n    beam_job_api_pb2_grpc.add_JobServiceServicer_to_server(self, self._server)\n    beam_artifact_api_pb2_grpc.add_ArtifactStagingServiceServicer_to_server(\n        self._artifact_service, self._server)\n    hostname = self.get_service_address()\n    self._artifact_staging_endpoint = endpoints_pb2.ApiServiceDescriptor(\n        url='%s:%d' % (hostname, port))\n    self._server.start()\n    _LOGGER.info('Grpc server started at %s on port %d' % (hostname, port))\n    return port\n\n  def stop(self, timeout=1):\n    self._server.stop(timeout)\n    if os.path.exists(self._staging_dir) and self._cleanup_staging_dir:\n      shutil.rmtree(self._staging_dir, ignore_errors=True)\n\n  def GetJobMetrics(self, request, context=None):\n    if request.job_id not in self._jobs:\n      raise LookupError(\"Job {} does not exist\".format(request.job_id))\n\n    result = self._jobs[request.job_id].result\n    if result is None:\n      monitoring_info_list = []\n    else:\n      monitoring_info_list = result.monitoring_infos()\n\n    # Filter out system metrics\n    user_monitoring_info_list = [\n        x for x in monitoring_info_list\n        if monitoring_infos.is_user_monitoring_info(x)\n    ]\n\n    return beam_job_api_pb2.GetJobMetricsResponse(\n        metrics=beam_job_api_pb2.MetricResults(\n            committed=user_monitoring_info_list))\n\n","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/portability/local_job_service.py#L138-L174","documentation":"LocalJobService.GetJobMetrics looks up the requested job_id in its _jobs registry and raises LookupError if the id is unknown. This is a client-facing gRPC servicer method, so requesting metrics for a job the local server never started (or has since discarded) produces this error.","triggerScenarios":"Calling GetJobMetrics with a job_id that was never submitted to this local_job_service instance, a mistyped id, or an id from a previous server process that has since restarted.","commonSituations":"Sharing job ids across separate local runner invocations; server restarted between job submission and metrics query; copy/paste typos in --job_id; querying a job served by a different BeamFnApiRunner instance.","solutions":["Use the job_id returned by the SubmitJob/RunJob response for this server instance.","Verify the local job service process is still the same one that ran the job (no restart).","List/track jobs you submitted (e.g. keep the result handle) rather than reconstructing ids.","Re-run the pipeline if its job record was lost on restart, then query metrics from the new id."],"exampleFix":"// before\nservice.GetJobMetrics(request(job_id='job_0042'))  # guessed id\n// after\nresult, job_id = service.RunJob(...)  # keep returned job_id\nservice.GetJobMetrics(request(job_id=job_id))","handlingStrategy":"try-catch","validationCode":"if not job_id or job_id not in known_job_ids:\n    raise SystemExit('unknown job_id: %s' % job_id)","typeGuard":"def job_known(service, job_id): return job_id in service._jobs","tryCatchPattern":"try:\n    metrics = service.GetJobMetrics(req)\nexcept LookupError:\n    log.warning('job %s not found on this server', req.job_id)","preventionTips":["Persist the job_id returned by RunJob","Query metrics from the same server instance that ran the job","Don't reuse ids across server restarts"],"tags":["grpc","job-management","lookup","beam"],"backgroundTag":"entity-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}