{"record":{"id":"fc98d98d7eca2d52","repo":"invoke-ai/InvokeAI","slug":"requiredconnectionexception","errorCode":null,"errorMessage":"RequiredConnectionException","messagePattern":"RequiredConnectionException","errorType":"validation","errorClass":"RequiredConnectionException","httpStatus":null,"severity":"error","filePath":"invokeai/app/invocations/baseinvocation.py","lineNumber":234,"sourceCode":"        Internal invoke method, calls `invoke()` after some prep.\n        Handles optional fields that are required to call `invoke()` and invocation cache.\n        \"\"\"\n        for field_name, field in type(self).model_fields.items():\n            if not field.json_schema_extra or callable(field.json_schema_extra):\n                # something has gone terribly awry, we should always have this and it should be a dict\n                continue\n\n            # Here we handle the case where the field is optional in the pydantic class, but required\n            # in the `invoke()` method.\n\n            orig_default = field.json_schema_extra.get(\"orig_default\", PydanticUndefined)\n            orig_required = field.json_schema_extra.get(\"orig_required\", True)\n            input_ = field.json_schema_extra.get(\"input\", None)\n            if orig_default is not PydanticUndefined and not hasattr(self, field_name):\n                setattr(self, field_name, orig_default)\n            if orig_required and orig_default is PydanticUndefined and getattr(self, field_name) is None:\n                if input_ == Input.Connection:\n                    raise RequiredConnectionException(type(self).model_fields[\"type\"].default, field_name)\n                elif input_ == Input.Any:\n                    raise MissingInputException(type(self).model_fields[\"type\"].default, field_name)\n\n        # skip node cache codepath if it's disabled\n        if services.configuration.node_cache_size == 0:\n            return self.invoke(context)\n\n        output: BaseInvocationOutput\n        if self.use_cache:\n            key = services.invocation_cache.create_key(self)\n            cached_value = services.invocation_cache.get(key)\n            if cached_value is None:\n                services.logger.debug(f'Invocation cache miss for type \"{self.get_type()}\": {self.id}')\n                output = self.invoke(context)\n                services.invocation_cache.save(key, output)\n                return output\n            else:\n                services.logger.debug(f'Invocation cache hit for type \"{self.get_type()}\": {self.id}')","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/invoke-ai/InvokeAI/blob/0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06/invokeai/app/invocations/baseinvocation.py#L216-L252","documentation":"RequiredConnectionException is raised during node validation in invoke_internal when an input field declared with Input.Connection is None at execution time. It means the node has a required field that can only be filled by an edge coming from another node, and no such connection (or no output from the connected node) supplied a value. The linear graph executor refuses to run the node rather than pass None downstream.","triggerScenarios":"Executing a graph where a node's Input.Connection field (e.g. an image or latents input) has no incoming edge, or the edge source node failed/was skipped so the value is None. Also triggered when running a node directly (e.g. via run_node) without wiring required inputs.","commonSituations":"Graphs edited in the workflow editor with a deleted edge; programmatic graph construction missing edges; a batch or iteration expander removing the intended edge; calling run_node in tests on a node whose required connection was never set.","solutions":["Add the missing edge in the graph so the required field receives output from an upstream node before invoking.","Verify the upstream node actually executes and produces output (check upstream node failures first).","If the field should not be required, change it to have a default value or declare input=Input.Any/Input.Direct with a default.","In tests, construct the invocation with all connection inputs populated instead of relying on defaults."],"exampleFix":"// before\nimage = ImageField(image_name=\"\")  # never connected\n\n// after\ngraph.add_edge(\n  source=EdgeConnection(node_id=\"load_image\", field=\"image\"),\n  destination=EdgeConnection(node_id=\"my_node\", field=\"image\"),\n)","handlingStrategy":"validation","validationCode":"# before invoking, verify every Input.Connection field on each node has an incoming edge\nconnected = {(e.destination.node_id, e.destination.field) for e in graph.edges.values()}\nfor node in graph.nodes.values():\n    for name, field in type(node).model_fields.items():\n        extra = field.json_schema_extra or {}\n        if extra.get(\"input\") == Input.Connection and extra.get(\"orig_required\", True):\n            if getattr(node, name, None) is None and (node.id, name) not in connected:\n                raise ValueError(f\"node {node.id}: missing connection for '{name}'\")","typeGuard":null,"tryCatchPattern":"try:\n    result = run_node(node, context)\nexcept RequiredConnectionException as e:\n    logger.error(\"node %s missing connection on field %s\", e.node_id, e.field_name)","preventionTips":["Validate graph connectivity before queueing a session","Never delete upstream nodes without re-wiring their consumers","In tests, build invocations with all connection inputs set explicitly"],"tags":["invocation-graph","missing-edge","input-validation"],"backgroundTag":"missing-required-input","analyzedSha":"0b6a024f2ff6a86bfb953dcdb9cc504ef7397a06","analyzedAt":"2026-08-29T04:46:49.967Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}