{"record":{"id":"c5a0fbdcbda6bc00","repo":"immich-app/immich","slug":"task-entry-task-of-type-entry-type-depen","errorCode":null,"errorMessage":"Task {entry['task']} of type {entry['type']} depends on output of {dep}","messagePattern":"Task (.+?) of type (.+?) depends on output of (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"machine-learning/immich_ml/main.py","lineNumber":199,"sourceCode":"    response = await run_inference(inputs, entries)\n    return ORJSONResponse(response)\n\n\nasync def run_inference(payload: Image | str, entries: InferenceEntries) -> InferenceResponse:\n    outputs: dict[ModelIdentity, Any] = {}\n    response: InferenceResponse = {}\n\n    async def _run_inference(entry: InferenceEntry) -> None:\n        model = await model_cache.get(\n            entry[\"name\"], entry[\"type\"], entry[\"task\"], ttl=settings.model_ttl, **entry[\"options\"]\n        )\n        inputs = [payload]\n        for dep in model.depends:\n            try:\n                inputs.append(outputs[dep])\n            except KeyError:\n                message = f\"Task {entry['task']} of type {entry['type']} depends on output of {dep}\"\n                raise HTTPException(400, message)\n        model = await load(model)\n        output = await run(model.predict, *inputs, **entry[\"options\"])\n        outputs[model.identity] = output\n        response[entry[\"task\"]] = output\n\n    without_deps, with_deps = entries\n    await asyncio.gather(*[_run_inference(entry) for entry in without_deps])\n    if with_deps:\n        await asyncio.gather(*[_run_inference(entry) for entry in with_deps])\n    if isinstance(payload, Image):\n        response[\"imageHeight\"], response[\"imageWidth\"] = payload.height, payload.width\n\n    return response\n\n\nasync def run(func: Callable[..., T], *args: Any, **kwargs: Any) -> T:\n    if thread_pool is None:\n        return func(*args, **kwargs)","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/machine-learning/immich_ml/main.py#L181-L217","documentation":"_run_inference executes each requested model task in order; a model may declare dependencies on outputs of earlier tasks (e.g. face detection feeding facial recognition). If a dependency's output is missing from the outputs map (KeyError), it raises HTTP 400 naming the task, type, and missing dependency.","triggerScenarios":"Requesting an inference config where a dependent task (e.g. facial-recognition) is listed without its prerequisite (e.g. face-detection) in the same request, or the prerequisite's output key differs from model.depends entries.","commonSituations":"Custom/simplified inference configs omitting the detection step; version mismatch where the server's config omits a task the ML service expects; typo in the dep name in a hand-written config.","solutions":["Include all prerequisite tasks in the request config in the correct order (e.g. both face-detection and facial-recognition).","Use the server-provided config rather than hand-crafted ones so dependencies are always present.","Ensure server and ML service versions match so generated configs include required tasks."],"exampleFix":"# before\n{\"facial-recognition\": {\"detection\": {}, \"recognition\": {}}}\n# after (include detection task so its output exists)\n{\"face-detection\": {\"detection\": {}}, \"facial-recognition\": {\"detection\": {}, \"recognition\": {}}}","handlingStrategy":"validation","validationCode":"# ensure prerequisite tasks are present in the request config\nrequired = {\"face-detection\", \"facial-recognition\"}\nassert required <= set(config.keys()), f\"missing deps: {required - set(config)}\"","typeGuard":null,"tryCatchPattern":"try:\n    r = requests.post(f\"{ml}/predict\", json={\"image\": b64, \"entries\": config})\n    r.raise_for_status()\nexcept requests.HTTPError as e:\n    if e.response.status_code == 400 and \"depends on output of\" in e.response.json().get(\"detail\", \"\"):\n        add_missing_task_and_retry(config)","preventionTips":["Use server-generated configs, never hand-crafted task lists.","Keep server and ML service versions in sync.","Order tasks so dependencies run before dependents."],"tags":["inference","dependency","fastapi","config"],"backgroundTag":"missing-dependency","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}