Description
The /customnode/getlist endpoint crashes with a KeyError when the mode query parameter is not provided in the request. The handler at glob/manager_server.py:877 accesses request.rel_url.query["mode"] directly without a default value, while the skip_update parameter on line 872 correctly uses .get().
Steps to Reproduce
- Send a GET request to
/customnode/getlist without the mode query parameter
- The server throws a
KeyError: 'mode'
Error Traceback
Error handling request from 127.0.0.1
Traceback (most recent call last):
File ".../aiohttp/web_protocol.py", line 510, in _handle_request
resp = await request_handler(request)
File ".../aiohttp/web_app.py", line 569, in _handle
return await handler(request)
...
File ".../ComfyUI-Manager/glob/manager_server.py", line 877, in fetch_customnode_list
if request.rel_url.query["mode"] == "local":
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: 'mode'
Root Cause
In glob/manager_server.py, the fetch_customnode_list handler uses direct dictionary access request.rel_url.query["mode"] on lines 877, 882, and 883, which raises KeyError if mode is not present.
Note that skip_update on line 872 already uses the safe .get() pattern:
if request.rel_url.query.get("skip_update", '').lower() == "true": # ✅ safe
But mode does not:
if request.rel_url.query["mode"] == "local": # ❌ KeyError if missing
Suggested Fix
Use request.rel_url.query.get("mode", "default") (or an appropriate default value) instead of direct dictionary access on lines 877, 882, and 883. For example:
mode = request.rel_url.query.get("mode", "cache")
if mode == "local":
channel = 'local'
else:
channel = core.get_config()['channel_url']
node_packs = await core.get_unified_total_nodes(channel, mode, 'cache')
json_obj_github = core.get_data_by_mode(mode, 'github-stats.json', 'default')
json_obj_extras = core.get_data_by_mode(mode, 'extras.json', 'default')
Environment
- ComfyUI-Manager version: 3.39.3
- ComfyUI version: latest master
- Python: 3.12
- OS: macOS
Description
The
/customnode/getlistendpoint crashes with aKeyErrorwhen themodequery parameter is not provided in the request. The handler atglob/manager_server.py:877accessesrequest.rel_url.query["mode"]directly without a default value, while theskip_updateparameter on line 872 correctly uses.get().Steps to Reproduce
/customnode/getlistwithout themodequery parameterKeyError: 'mode'Error Traceback
Root Cause
In
glob/manager_server.py, thefetch_customnode_listhandler uses direct dictionary accessrequest.rel_url.query["mode"]on lines 877, 882, and 883, which raisesKeyErrorifmodeis not present.Note that
skip_updateon line 872 already uses the safe.get()pattern:But
modedoes not:Suggested Fix
Use
request.rel_url.query.get("mode", "default")(or an appropriate default value) instead of direct dictionary access on lines 877, 882, and 883. For example:Environment