From 1339cb570dc0d2e6b463165dfdf737ddcc956fba Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Mon, 1 Jun 2026 23:39:20 -0700 Subject: [PATCH] Coalesce empty query params to None in /node_startup_errors route ?source= or ?module_name= or ?pack_id= (param present but blank) would have returned {} because the helper treated the empty string as an exact-match filter. Coalesce to None at the route boundary so a present-but-blank query param behaves the same as the param being absent. The helper's own behaviour is unchanged and locked in by a new assertion. Amp-Thread-ID: https://ampcode.com/threads/T-019e86fd-b68f-74de-8c91-d2662377424a Co-authored-by: Amp --- server.py | 9 ++++++--- tests-unit/node_startup_errors_test.py | 5 +++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/server.py b/server.py index 4f22efb68..8ca6622f6 100644 --- a/server.py +++ b/server.py @@ -795,10 +795,13 @@ class PromptServer(): result still returns ``{}`` with HTTP 200 rather than 404 — absence of an error is a valid answer for this endpoint. """ + # Coalesce empty-string query values to None so `?source=` (param + # present but blank) is treated the same as the param being absent + # — rather than filtering for entries whose source is literally "". grouped = nodes.filter_node_startup_errors( - source=request.query.get("source"), - module_name=request.query.get("module_name"), - pack_id=request.query.get("pack_id"), + source=request.query.get("source") or None, + module_name=request.query.get("module_name") or None, + pack_id=request.query.get("pack_id") or None, ) return web.json_response(grouped) diff --git a/tests-unit/node_startup_errors_test.py b/tests-unit/node_startup_errors_test.py index cf66f8e3b..0afe01fc4 100644 --- a/tests-unit/node_startup_errors_test.py +++ b/tests-unit/node_startup_errors_test.py @@ -218,6 +218,11 @@ def test_filter_node_startup_errors_source_filter(): assert set(grouped["comfy_extras"]) == {"B"} # Non-matching source filter returns an empty dict, not an error. assert nodes.filter_node_startup_errors(source="nope") == {} + # An explicit empty-string filter is treated as a real value (matches + # entries whose source is literally ""), NOT silently as "no filter". + # The HTTP route layer is responsible for coalescing `?source=` to None + # before calling this helper; this assertion locks that contract in. + assert nodes.filter_node_startup_errors(source="") == {} def test_filter_node_startup_errors_module_name_filter():