diff --git a/py/nodes.py b/py/nodes.py index f8b9127..d241aa3 100644 --- a/py/nodes.py +++ b/py/nodes.py @@ -704,8 +704,8 @@ def _register_output_asset(file_path): try: ingest_existing_file(file_path) - except Exception as e: - print(f"[PreviewVideo] Failed to register output asset: {e}") + except Exception: + return def _build_local_media_view_url(filename, subfolder, folder_type): @@ -1565,8 +1565,8 @@ class PreviewVideo: handle.write(_fetch_image(video_url)) try: _register_output_asset(file_path) - except Exception as e: - print(f"[PreviewVideo] Failed to register output asset: {e}") + except Exception: + pass return { "ui": { diff --git a/tests/test_backend_config.py b/tests/test_backend_config.py index 16a58e7..2d9529d 100644 --- a/tests/test_backend_config.py +++ b/tests/test_backend_config.py @@ -195,6 +195,31 @@ class BackendConfigTests(unittest.TestCase): ): kling_nodes._register_output_asset("example.mp4") + def test_preview_video_silences_broken_asset_ingest_function(self): + fake_app_module = ModuleType("app") + fake_assets_module = ModuleType("app.assets") + fake_services_module = ModuleType("app.assets.services") + fake_ingest_module = ModuleType("app.assets.services.ingest") + + def broken_ingest(_file_path): + raise TypeError("'NoneType' object is not callable") + + fake_ingest_module.ingest_existing_file = broken_ingest + + with mock.patch.dict( + sys.modules, + { + "app": fake_app_module, + "app.assets": fake_assets_module, + "app.assets.services": fake_services_module, + "app.assets.services.ingest": fake_ingest_module, + }, + ): + with mock.patch("builtins.print") as print_mock: + kling_nodes._register_output_asset("example.mp4") + + print_mock.assert_not_called() + def test_preview_video_keeps_result_when_asset_registration_fails(self): with tempfile.TemporaryDirectory() as tmpdir: tmpdir_path = Path(tmpdir)