{"record":{"id":"236ed48fee732a1a","repo":"invoke-ai/InvokeAI","slug":"workflow-return-key-key-was-not-found","errorCode":null,"errorMessage":"Workflow return key '{key}' was not found.","messagePattern":"Workflow return key '(.+?)' was not found\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/workflow_return.py","lineNumber":138,"sourceCode":")\nclass WorkflowReturnGetInvocation(BaseInvocation):\n    \"\"\"Extracts one named value from a callable workflow return.\"\"\"\n\n    values: dict[str, Any] = InputField(\n        default={},\n        description=\"The named workflow return values.\",\n        title=\"Values\",\n        ui_type=UIType.Any,\n        input=Input.Connection,\n    )\n    key: str = InputField(default=\"\", description=\"The return key to extract.\", title=\"Key\")\n\n    def invoke(self, context: InvocationContext) -> WorkflowReturnGetOutput:\n        key = self.key.strip()\n        if not key:\n            raise ValueError(\"Workflow return key must not be empty.\")\n        if key not in self.values:\n            raise ValueError(f\"Workflow return key '{key}' was not found.\")\n        return WorkflowReturnGetOutput(value=self.values[key])\n","sourceCodeStart":120,"sourceCodeEnd":140,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/workflow_return.py#L120-L140","documentation":"Workflow Return Get looks up self.key in the workflow's named return values dict. If the stripped key is non-empty but not present among the values the workflow returned, invoke() raises ValueError naming the missing key. This guards against typos and keys removed from the return node.","triggerScenarios":"invoke() on a WorkflowReturnGet invocation where self.key (after .strip()) is not a key in the values dict produced by the workflow-return invocation, e.g. the return node no longer emits 'result' but the get node still requests it.","commonSituations":"Renaming or deleting a key on the workflow-return node while downstream get nodes still reference the old name; importing a workflow whose return keys changed between versions; a case/whitespace mismatch between the two key fields.","solutions":["Align the get node's 'key' with an existing key on the workflow-return node's values list","Check exact spelling, case, and surrounding whitespace of both key fields","Re-run the workflow and inspect which keys the return node actually emits","Update stale workflow JSON so get nodes reference current return keys"],"exampleFix":"// before\nget = WorkflowReturnGetInvocation(values=return_values, key='outpt')\n// after\nget = WorkflowReturnGetInvocation(values=return_values, key='output')","handlingStrategy":"validation","validationCode":"def key_exists(invocation, return_values):\n    k = invocation.key.strip()\n    return k in return_values\n\nif not key_exists(invocation, return_values):\n    raise KeyError(f\"'{invocation.key}' not in workflow return keys: {list(return_values)}\")","typeGuard":null,"tryCatchPattern":"try:\n    output = invocation.invoke(context)\nexcept ValueError as e:\n    if \"was not found\" in str(e):\n        log_missing_return_key(extract_key_from_message(str(e)))\n    else:\n        raise","preventionTips":["Rename return keys at the source and update all get nodes in the same edit","Diff imported workflow JSON against current key names","Use consistent casing; treat keys as case-sensitive"],"tags":["workflow","key-lookup","validation"],"backgroundTag":"key-not-found","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}