fix: report background images that cannot be converted

A tensor that Pillow could not turn into an image raised out of the node
and failed the workflow. The documented console warning never ran.
This commit is contained in:
by-ae
2026-10-29 07:48:02 +10:00
parent cd9df07f38
commit bc763779fb
2 changed files with 19 additions and 1 deletions
+8 -1
View File
@@ -210,7 +210,14 @@ def save_bg_image_to_temp(guid, image):
exc, raw_guid,
)
return None
pil = _tensor_to_pil(image)
try:
pil = _tensor_to_pil(image)
except Exception as exc:
_bg_warn(
"background image was not saved: could not convert the image tensor (guid=%s): %s",
safe_guid, exc,
)
return None
if pil is None:
_bg_warn("background image was not saved: could not convert the image tensor (guid=%s)", safe_guid)
return None
+11
View File
@@ -2,6 +2,7 @@
import json
import unittest
from unittest.mock import MagicMock, patch
# conftest.py handles mocking and path setup
from nodes.ideogram4_nodes import (
@@ -400,6 +401,16 @@ class TestPromptHelpers(unittest.TestCase):
self.assertIsNone(result)
self.assertTrue(any("invalid background guid" in line.lower() for line in cm.output))
def test_save_bg_image_warns_when_conversion_fails(self):
guid = "12345678-1234-4abc-8abc-123456789012"
image_mod = save_bg_image_to_temp.__globals__["Image"]
with patch.object(image_mod, "fromarray", side_effect=ValueError("bad shape")):
with self.assertLogs("byae.ideogram.bg", level="WARNING") as cm:
result = save_bg_image_to_temp(guid, MagicMock())
self.assertIsNone(result)
self.assertTrue(any("could not convert" in line.lower() for line in cm.output))
self.assertTrue(any("bad shape" in line for line in cm.output))
class TestPromptAssembly(unittest.TestCase):
"""Test full prompt assembly logic without ComfyUI runtime."""