Debugging ComfyUI PHP Integration: Solving the ‘list’ object Error

We’re debugging a frustrating integration issue today. A PHP script is trying to call a workflow in ComfyUI, but it’s crashing with a generic HTTP 500 Internal Server Error. At first glance, this looks like a simple server-side crash, so the initial instinct is to check the web server logs.

An illustration of a PHP script failing to connect to ComfyUI due to an internal server error.
The initial HTTP 500 error encountered when calling the workflow from PHP.

Finding the Real Culprit

However, after checking the ComfyUI console logs and re-running the script, we find a much more specific traceback. The error isn’t in PHP at all; it’s happening inside Python within ComfyUI itself. The traceback points directly to node_replace_manager.py, line 72:

AttributeError: 'list' object has no attribute 'items'

This is a clear indicator of a structural mismatch in the data being passed.

Analyzing the PHP Code

We look at the specific assignment code provided from the PHP script:

$prompt = "Genera un video";
$job["141:134"]["inputs"]["prompt"] = $prompt;

At first, this looks perfectly valid. The code is assigning a string to an existing key in the $job array, and that specific node’s inputs are clearly defined as objects.

A screenshot of a terminal window showing the AttributeError traceback in Python code.
The Python traceback from ComfyUI's console revealing the root cause.

The Hidden Issue

If that specific assignment is correct, why is ComfyUI still throwing this error? The traceback reveals that when iterating through the nodes using .items(), it encounters a node where inputs is actually an array (a list) instead of a dictionary (an object).

We also notice that some workflow IDs, like 141:134, suggest the use of subgraphs or nested workflows. This adds a layer of complexity to how the data structure is being parsed.

A diagram showing the difference between correct and incorrect JSON input structures for ComfyUI nodes.
Visual comparison of valid dictionary inputs versus invalid list inputs in the workflow JSON.

The Debugging Plan

To pinpoint exactly which node is causing this structural failure, we need to inspect the entire workflow object before it reaches ComfyUI. We will implement a loop that iterates through every single node in $job. This script will check if any node’s inputs key contains a list.

We’ll also save the final JSON payload to a file like job-debug.json. By comparing this saved file with what PHP is receiving, we can see exactly where in the process the data structure is being corrupted or altered. This will allow us to fix the root cause and get the integration working correctly.