{"record":{"id":"4cb0ebc1d656c43c","repo":"Comfy-Org/ComfyUI","slug":"unexpected-response-the-first-item-is-not-the-bas","errorCode":null,"errorMessage":"Unexpected response: the first item is not the base image.","messagePattern":"Unexpected response: the first item is not the base image\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"comfy_api_nodes/nodes_bytedance.py","lineNumber":1262,"sourceCode":"            if isinstance(v, (int, float)):\n                return int(v)\n            if isinstance(v, str):\n                try:\n                    return int(v.strip())\n                except ValueError:\n                    return 1_000_000\n            return 1_000_000\n\n        data = [d for d in (response.data or []) if isinstance(d, dict)]\n        if not data or \"url\" not in data[0]:\n            raise RuntimeError(\"Unexpected response: no base image returned.\")\n        base_item = data[0]\n        if base_item.get(\"bounding_box\") is not None:\n            logging.warning(\n                \"ByteDance layer separation: base item unexpectedly carries a bounding_box; ignoring it.\"\n            )\n        if z_index_of(base_item) not in (0, 1_000_000):\n            raise RuntimeError(\"Unexpected response: the first item is not the base image.\")\n        layer_items = [d for d in data[1:] if \"url\" in d]\n        dropped = len(data) - 1 - len(layer_items)\n        if dropped > 0:\n            logging.warning(\n                \"ByteDance layer separation: %d of %d returned elements had no 'url' and were dropped.\",\n                dropped,\n                len(data) - 1,\n            )\n        if not layer_items:\n            raise RuntimeError(\"The model returned no layers. Try a different prompt or input image.\")\n        layer_items.sort(key=z_index_of)\n\n        base_image = (await download_url_to_image_tensor(str(base_item[\"url\"])))[..., :3].contiguous()\n        height, width = base_image.shape[1], base_image.shape[2]\n\n        specs = []\n        for item in layer_items:\n            flags = []","sourceCodeStart":1244,"sourceCodeEnd":1280,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_api_nodes/nodes_bytedance.py#L1244-L1280","documentation":"Raised by ByteDanceSeedreamLayerSeparationNode when the first item's z_index is neither 0 nor 1,000,000 (the sentinel used for missing/unparseable z_index). The node requires the first item to be the base image; a non-base first item means the ordering contract of the response was violated.","triggerScenarios":"The API returns a layer (not the base) first, carrying an explicit z_index other than 0; z_index_of parses a value like 2 or 5 for data[0].","commonSituations":"BytePlus changes the ordering of returned items or adds new z_index semantics; a response contract change shipped server-side.","solutions":["Retry once — ordering anomalies can be transient.","Update ComfyUI to the newest version, since the z-index heuristics may have been updated for a new API behavior.","File a bug with the raw response from ComfyUI/temp/api_logs/ attached."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"except RuntimeError as e:\n    if 'first item is not the base image' in str(e):\n        result = await separate_layers(image)  # one retry; ordering anomalies are often transient\n        # if it repeats, report with api_logs payload\n    else:\n        raise","preventionTips":["Retry once on ordering-contract errors before investigating.","Keep the raw response from ComfyUI/temp/api_logs/ when filing issues."],"tags":["bytedance","seedream","layer-separation","unexpected-response","api-nodes"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}