[GH-ISSUE #2740] Bug: KeyError 'mode' in fetch_customnode_list when query parameter is missing #1025

Open
opened 2026-10-27 21:25:06 +00:00 by bsakaguchi · 0 comments
Owner

Originally created by @HuangYuChuh on GitHub (Mar 29, 2026).
Original GitHub issue: https://github.com/Comfy-Org/ComfyUI-Manager/issues/2740

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

  1. Send a GET request to /customnode/getlist without the mode query parameter
  2. 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
Originally created by @HuangYuChuh on GitHub (Mar 29, 2026). Original GitHub issue: https://github.com/Comfy-Org/ComfyUI-Manager/issues/2740 ## 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 1. Send a GET request to `/customnode/getlist` without the `mode` query parameter 2. 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: ```python if request.rel_url.query.get("skip_update", '').lower() == "true": # ✅ safe ``` But `mode` does not: ```python 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: ```python 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
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/ComfyUI-Manager#1025
No description provided.