{"record":{"id":"22c88b1b63dee91c","repo":"Comfy-Org/ComfyUI","slug":"node-id-must-be-provided-if-not-in-executing-conte","errorCode":null,"errorMessage":"node_id must be provided if not in executing context","messagePattern":"node_id must be provided if not in executing context","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_api/latest/__init__.py","lineNumber":55,"sourceCode":"            value: float,\n            max_value: float,\n            node_id: str | None = None,\n            preview_image: Image.Image | ImageInput | None = None,\n            ignore_size_limit: bool = False,\n        ) -> None:\n            \"\"\"\n            Update the progress bar displayed in the ComfyUI interface.\n\n            This function allows custom nodes and API calls to report their progress\n            back to the user interface, providing visual feedback during long operations.\n\n            Migration from previous API: comfy.utils.PROGRESS_BAR_HOOK\n            \"\"\"\n            executing_context = get_executing_context()\n            if node_id is None and executing_context is not None:\n                node_id = executing_context.node_id\n            if node_id is None:\n                raise ValueError(\"node_id must be provided if not in executing context\")\n\n            # Convert preview_image to PreviewImageTuple if needed\n            to_display: PreviewImageTuple | Image.Image | ImageInput | None = preview_image\n            if to_display is not None:\n                # First convert to PIL Image if needed\n                if isinstance(to_display, ImageInput):\n                    # Convert ImageInput (torch.Tensor) to PIL Image\n                    # Handle tensor shape [B, H, W, C] -> get first image if batch\n                    tensor = to_display\n                    if len(tensor.shape) == 4:\n                        tensor = tensor[0]\n\n                    # Convert to numpy array and scale to 0-255\n                    image_np = (tensor.cpu().numpy() * 255).astype(np.uint8)\n                    to_display = Image.fromarray(image_np)\n\n                if isinstance(to_display, Image.Image):\n                    # Detect image format from PIL Image","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api/latest/__init__.py#L37-L73","documentation":"comfy_api.latest's set_progress_bar / progress-reporting API needs to attribute progress to a node. It resolves node_id from the currently executing node's server-side context; when called outside execution (e.g. from a custom script, API request handler, or startup code) there is no executing context and no node_id argument, so it raises.","triggerScenarios":"Calling the progress/preview API (set_progress_bar-style function in comfy_api/latest/__init__.py) from code that runs outside a node execution — no get_executing_context() and node_id=None in kwargs.","commonSituations":"Custom nodes calling the progress hook in a background thread spawned at import time; API endpoint code reporting progress; migration from old comfy.utils.PROGRESS_BAR_HOOK usage that did not require node_id.","solutions":["Pass node_id explicitly: call the API with node_id='<the node being executed>' when outside the executing context","Move the progress call inside the node's execute path so the executing context supplies node_id","Guard the call: only report progress when get_executing_context() is not None or you have a real node_id"],"exampleFix":"// before\ncomfy_api.latest.set_progress_bar(0.5)  # called from a thread, no context\n\n# after\nnode_id = getattr(get_executing_context(), 'node_id', None)\nif node_id is not None:\n    comfy_api.latest.set_progress_bar(0.5, node_id=node_id)","handlingStrategy":"validation","validationCode":"ctx = comfy_api.latest.get_executing_context()\nif ctx is None and node_id is None:\n    skip_progress = True  # not inside execution; do not report","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass node_id explicitly in custom-node progress calls","Only call progress APIs from within the node's execute function"],"tags":["progress-bar","api","node-execution","custom-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}