{"record":{"id":"ab432ade783bb4ed","repo":"invoke-ai/InvokeAI","slug":"no-job-with-id-id-known","errorCode":null,"errorMessage":"No job with id {id} known","messagePattern":"No job with id (.+?) known","errorType":"exception","errorClass":"ValueError","httpStatus":404,"severity":"error","filePath":"invokeai/app/services/model_install/model_install_default.py","lineNumber":561,"sourceCode":"                self._install_condition.notify_all()\n            raise\n\n        with self._install_condition:\n            self._install_jobs.append(install_job)\n            self._pending_sources.remove(source_key)\n            self._install_condition.notify_all()\n        return install_job\n\n    def list_jobs(self) -> List[ModelInstallJob]:  # noqa D102\n        return self._install_jobs\n\n    def get_job_by_source(self, source: ModelSource) -> List[ModelInstallJob]:  # noqa D102\n        return [x for x in self._install_jobs if x.source == source]\n\n    def get_job_by_id(self, id: int) -> ModelInstallJob:  # noqa D102\n        jobs = [x for x in self._install_jobs if x.id == id]\n        if not jobs:\n            raise ValueError(f\"No job with id {id} known\")\n        assert len(jobs) == 1\n        assert isinstance(jobs[0], ModelInstallJob)\n        return jobs[0]\n\n    def wait_for_job(self, job: ModelInstallJob, timeout: int = 0) -> ModelInstallJob:\n        \"\"\"Block until the indicated job has reached terminal state, or when timeout limit reached.\"\"\"\n        start = time.time()\n        while not job.in_terminal_state:\n            if self._install_completed_event.wait(timeout=5):  # in case we miss an event\n                self._install_completed_event.clear()\n            if timeout > 0 and time.time() - start > timeout:\n                raise TimeoutError(\"Timeout exceeded\")\n        return job\n\n    def wait_for_installs(self, timeout: int = 0) -> List[ModelInstallJob]:  # noqa D102\n        \"\"\"Block until all installation jobs are done.\"\"\"\n        start = time.time()\n        restore_timeout = timeout if timeout > 0 else None","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/services/model_install/model_install_default.py#L543-L579","documentation":"ModelInstallService.get_job_by_id() looks up an install job by its integer id in the in-memory list of jobs. It throws ValueError when no job in the service's registry matches the given id, meaning the job was never started in this process or the registry entry is gone (e.g. after a restart, since jobs are not persisted).","triggerScenarios":"Calling get_job_by_id() with an id that was never created; using an id from a previous service run/restart (jobs live only in memory); passing a job id from a different service instance; integer/string mixups (id stored as string).","commonSituations":"API client resumes after server restart and reuses a stale job id; a UI polls a job that was cancelled and purged; tests construct jobs directly without registering them via the service.","solutions":["Verify the id came from a job returned by this same service instance in this process (e.g. from install() or get_job_by_source()).","List current jobs (e.g. via the jobs list/GET /install endpoints) and use a valid id.","After a service restart, re-list jobs instead of reusing persisted ids; if persistence is needed, store source info and re-lookup by source.","Ensure the id is an int, matching the x.id type stored on the job."],"exampleFix":"// before\njob = service.get_job_by_id(42)  # id from a previous session\n// after\njobs = service.get_job_by_source(HFModelSource(repo_id='author/model'))\nif not jobs:\n    raise RuntimeError('Job not found; service may have restarted')\njob = jobs[0]","handlingStrategy":"try-catch","validationCode":"ids = {j.id for j in service.get_jobs()} if hasattr(service, 'get_jobs') else None\n# or track ids returned by install():\nvalid_id = isinstance(job_id, int) and job_id in tracked_ids","typeGuard":"def job_exists(service, job_id: int) -> bool:\n    try:\n        service.get_job_by_id(job_id)\n        return True\n    except ValueError:\n        return False","tryCatchPattern":"try:\n    job = service.get_job_by_id(job_id)\nexcept ValueError:\n    job = None  # job unknown: service restarted or bad id; re-list or re-install","preventionTips":["Never persist and reuse job ids across service restarts; re-list jobs instead.","Capture ids only from values returned by install()/list endpoints of the same instance.","Always pass int ids, not strings.","On 'unknown', fall back to get_job_by_source() with the original source."],"tags":["api","state-management","valueerror"],"backgroundTag":"stale-resource-id","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}