Skip to content

Bug: KeyError 'mode' in fetch_customnode_list when query parameter is missing #2740

@HuangYuChuh

Description

@HuangYuChuh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions