{"record":{"id":"3433039eb71f7097","repo":"lllyasviel/Fooocus","slug":"unsupported-blend-mode-mode-343303","errorCode":null,"errorMessage":"Unsupported blend mode: {mode}","messagePattern":"Unsupported blend mode: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"ldm_patched/contrib/external_post_processing.py","lineNumber":63,"sourceCode":"        blended_image = image1 * (1 - blend_factor) + blended_image * blend_factor\n        blended_image = torch.clamp(blended_image, 0, 1)\n        return (blended_image,)\n\n    def blend_mode(self, img1, img2, mode):\n        if mode == \"normal\":\n            return img2\n        elif mode == \"multiply\":\n            return img1 * img2\n        elif mode == \"screen\":\n            return 1 - (1 - img1) * (1 - img2)\n        elif mode == \"overlay\":\n            return torch.where(img1 <= 0.5, 2 * img1 * img2, 1 - 2 * (1 - img1) * (1 - img2))\n        elif mode == \"soft_light\":\n            return torch.where(img2 <= 0.5, img1 - (1 - 2 * img2) * img1 * (1 - img1), img1 + (2 * img2 - 1) * (self.g(img1) - img1))\n        elif mode == \"difference\":\n            return img1 - img2\n        else:\n            raise ValueError(f\"Unsupported blend mode: {mode}\")\n\n    def g(self, x):\n        return torch.where(x <= 0.25, ((16 * x - 12) * x + 4) * x, torch.sqrt(x))\n\ndef gaussian_kernel(kernel_size: int, sigma: float, device=None):\n    x, y = torch.meshgrid(torch.linspace(-1, 1, kernel_size, device=device), torch.linspace(-1, 1, kernel_size, device=device), indexing=\"ij\")\n    d = torch.sqrt(x * x + y * y)\n    g = torch.exp(-(d * d) / (2.0 * sigma * sigma))\n    return g / g.sum()\n\nclass Blur:\n    def __init__(self):\n        pass\n\n    @classmethod\n    def INPUT_TYPES(s):\n        return {\n            \"required\": {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/ldm_patched/contrib/external_post_processing.py#L45-L81","documentation":"The image-space Blend node (external_post_processing) supports exactly six modes — normal, multiply, screen, overlay, soft_light, difference — and raises ValueError for anything else. The string comparison is exact/lowercase, so casing or whitespace breaks it. Note 'soft_light' uses an underscore, not a hyphen.","triggerScenarios":"Calling Blend.blend_images(img1, img2, mode=...) with values like 'add', 'lighten', 'soft-light', 'Soft_Light', or ' multiply' (leading space).","commonSituations":"Porting mode names from Photoshop/GIMP (which include 'lighten', 'color-dodge', etc.), typos from hand-edited workflow JSONs, or hyphen/underscore confusion between libraries.","solutions":["Use one of: 'normal', 'multiply', 'screen', 'overlay', 'soft_light', 'difference'.","Normalize input: mode = mode.strip().lower() before calling if user-supplied.","Validate mode against the allowed set in your UI/schema before queueing the job.","For unsupported modes like 'add', compute manually: img1 + img2 (clamped)."],"exampleFix":"# before\nout = blend.blend_images(a, b, mode='soft-light')  # ValueError\n\n# after\nout = blend.blend_images(a, b, mode='soft_light')","handlingStrategy":"validation","validationCode":"BLEND_MODES = {'normal', 'multiply', 'screen', 'overlay', 'soft_light', 'difference'}\nmode = mode.strip().lower()\nif mode not in BLEND_MODES:\n    raise ValueError(f'mode must be one of {sorted(BLEND_MODES)}, got {mode!r}')","typeGuard":"def is_supported_blend_mode(mode: str) -> bool:\n    return isinstance(mode, str) and mode.strip().lower() in {'normal', 'multiply', 'screen', 'overlay', 'soft_light', 'difference'}","tryCatchPattern":"try:\n    out = blend.blend_images(img1, img2, mode)\nexcept ValueError as e:\n    if 'blend mode' in str(e):\n        raise ValueError(f'{mode!r} unsupported; allowed: normal/multiply/screen/overlay/soft_light/difference') from e\n    raise","preventionTips":["Constrain UI dropdowns and JSON schemas to the six supported mode strings.","Normalize (strip + lower) user-supplied mode strings before use.","Remember the underscore form 'soft_light', not 'soft-light'."],"tags":["comfyui","blend-mode","post-processing","image-ops"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}