{"record":{"id":"1b563f0e3aacd867","repo":"Comfy-Org/ComfyUI","slug":"number-of-positive-conditions-len-positive-do","errorCode":null,"errorMessage":"Number of positive conditions ({len(positive)}) does not match number of images ({num_images}).","messagePattern":"Number of positive conditions \\((.+?)\\) does not match number of images \\((.+?)\\)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"comfy_extras/nodes_train.py","lineNumber":669,"sourceCode":"    Args:\n        positive: Conditioning list\n        num_images: Number of images\n        bucket_mode: Whether bucket mode is enabled\n\n    Returns:\n        Validated/expanded conditioning list\n\n    Raises:\n        ValueError: If conditioning count doesn't match image count\n    \"\"\"\n    if bucket_mode:\n        return positive  # Skip validation in bucket mode\n\n    logging.debug(f\"Total Images: {num_images}, Total Captions: {len(positive)}\")\n    if len(positive) == 1 and num_images > 1:\n        return positive * num_images\n    elif len(positive) != num_images:\n        raise ValueError(\n            f\"Number of positive conditions ({len(positive)}) does not match number of images ({num_images}).\"\n        )\n    return positive\n\n\ndef _load_existing_lora(existing_lora):\n    \"\"\"Load existing LoRA weights if provided.\n\n    Args:\n        existing_lora: LoRA filename or \"[None]\"\n\n    Returns:\n        tuple: (existing_weights dict, existing_steps int)\n    \"\"\"\n    if existing_lora == \"[None]\":\n        return {}, 0\n\n    lora_path = folder_paths.get_full_path_or_raise(\"loras\", existing_lora)","sourceCodeStart":651,"sourceCodeEnd":687,"githubUrl":"https://github.com/Comfy-Org/ComfyUI/blob/1c6d8d45b3693bfbb32385b410d813a7fd6be216/comfy_extras/nodes_train.py#L651-L687","documentation":"In the training-node conditioning validation helper, when bucket_mode is off, the number of positive conditions must equal the number of training images (a single condition may be broadcast to all images). Any other count mismatch raises this error so the trainer does not silently pair images with the wrong captions.","triggerScenarios":"Calling the training node with, say, 8 images and 3 positive conditioning entries (and not exactly 1), with bucket_mode disabled. Bucket mode skips the check entirely and returns the list unchanged.","commonSituations":"Caption folder has a different file count than the image folder; some images failed to load upstream changing num_images; a batch-size or dataloader change desynchronized captions from images; user assumed captions broadcast but supplied 2+ entries.","solutions":["Make the number of positive conditions match the number of images exactly, or supply exactly one condition to broadcast","Audit the caption list for missing/extra entries relative to the image dataset","If the mismatch is intentional and buckets handle grouping, enable bucket_mode which skips this validation"],"exampleFix":"# before: 8 images, 3 captions\npositive = [c1, c2, c3]\n\n# after: one caption broadcast to all images\npositive = [c1] * 8  # or exactly 8 caption entries","handlingStrategy":"validation","validationCode":"if not bucket_mode:\n    if len(positive) == 1:\n        positive = positive * num_images\n    elif len(positive) != num_images:\n        raise ValueError(f\"captions={len(positive)} images={num_images}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write dataset prep scripts that assert caption count == image count before training","Remember exactly one caption broadcasts; any other count must match"],"tags":["training","conditioning","dataset","validation"],"backgroundTag":null,"analyzedSha":"1c6d8d45b3693bfbb32385b410d813a7fd6be216","analyzedAt":"2026-08-14T19:37:18.893Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}