mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-06-05 20:55:24 +00:00
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 <amp@ampcode.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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():
|
||||
|
||||
Reference in New Issue
Block a user