Compare commits

...
Author SHA1 Message Date
Dr.Lt.Data 1293514fc8 A list request without mode is answered
`GET /v2/customnode/getmappings` of both servers, and
`/v2/customnode/getlist` and `/v2/externalmodel/getlist` of the legacy
server, read `mode` with `request.rel_url.query["mode"]` and answered
500 with `KeyError: 'mode'` for a request without it (#2740).

- The four handlers read `mode` with `cache` as its default
- Add a test for the four handlers: a request without `mode` gets the
  answer of `mode=cache`, which is not the answer of `mode=local`
- `tests/test_legacy_secgate_other_paths.py` puts back the `get_data` that
  it replaces for its own cases. It left the replacement in place, and a
  test that ran after it read no file
- Add a CHANGELOG entry

The same change for main is #2741.
2026-12-03 17:20:17 +09:00
5 changed files with 49 additions and 9 deletions
+7
View File
@@ -44,6 +44,13 @@ and this project adheres to [Semantic Versioning 2.0.0](https://semver.org/spec/
### Fixed
- A list request without `mode` is answered. `GET /v2/customnode/getmappings`
and, with the legacy UI, `/v2/customnode/getlist` and
`/v2/externalmodel/getlist` answered 500 with `KeyError: 'mode'` when the
request had no `mode` (#2740). Such a request is now answered as one with
`mode=cache`. The legacy pages always send `mode`, so nothing changes for
them.
- The Version column of the legacy Custom Nodes Manager no longer shows an
older registry version as an update. The column showed `[↑<version>]`
whenever the installed version was not the latest version of the registry,
+1 -1
View File
@@ -1427,7 +1427,7 @@ async def fetch_customnode_mappings(request):
"""
provide unified (node -> node pack) mapping list
"""
mode = request.rel_url.query["mode"]
mode = request.rel_url.query.get("mode", "cache")
nickname_mode = False
if mode == "nickname":
+8 -6
View File
@@ -875,7 +875,7 @@ async def fetch_customnode_mappings(request):
"""
provide unified (node -> node pack) mapping list
"""
mode = request.rel_url.query["mode"]
mode = request.rel_url.query.get("mode", "cache")
nickname_mode = False
if mode == "nickname":
@@ -1134,14 +1134,16 @@ async def fetch_customnode_list(request):
"""
provide unified custom node list
"""
if request.rel_url.query["mode"] == "local":
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, request.rel_url.query["mode"], 'cache')
json_obj_github = core.get_data_by_mode(request.rel_url.query["mode"], 'github-stats.json', 'default')
json_obj_extras = core.get_data_by_mode(request.rel_url.query["mode"], 'extras.json', 'default')
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')
core.populate_github_stats(node_packs, await json_obj_github)
core.populate_favorites(node_packs, await json_obj_extras)
@@ -1237,7 +1239,7 @@ def check_model_installed(json_obj):
@routes.get("/v2/externalmodel/getlist")
async def fetch_externalmodel_list(request):
# The model list is only allowed in the default channel, yet.
json_obj = await core.get_data_by_mode(request.rel_url.query["mode"], 'model-list.json')
json_obj = await core.get_data_by_mode(request.rel_url.query.get("mode", "cache"), 'model-list.json')
check_model_installed(json_obj)
+5 -2
View File
@@ -52,6 +52,7 @@ from _install_flags_testutil import ( # noqa: E402
)
_LEGACY_SERVER = None
_GET_DATA = None
def _import_legacy_server():
@@ -59,7 +60,7 @@ def _import_legacy_server():
(idempotent; memoized). Returns the real module object so the tests drive
the REAL gate function and REAL handlers — only the runtime *environment*
is stubbed, never the gate logic."""
global _LEGACY_SERVER
global _LEGACY_SERVER, _GET_DATA
if _LEGACY_SERVER is not None:
return _LEGACY_SERVER
@@ -108,6 +109,7 @@ def _import_legacy_server():
async def _inert_get_data(uri, *a, **k):
return {"custom_nodes": [], "models": [], "node_map": {}}
_GET_DATA = mu.get_data
mu.get_data = _inert_get_data
_LEGACY_SERVER = importlib.import_module("comfyui_manager.legacy.manager_server")
@@ -116,7 +118,8 @@ def _import_legacy_server():
@pytest.fixture(scope="module")
def ms():
return _import_legacy_server()
yield _import_legacy_server()
sys.modules["comfyui_manager.common.manager_util"].get_data = _GET_DATA
@pytest.fixture
+28
View File
@@ -0,0 +1,28 @@
import asyncio
import json
import re
from types import SimpleNamespace
import pytest
from aiohttp import web
from legacy_html_testutil import PACKAGE, load_functions
from test_default_channel import COMFY_ORG, configure, registry, route, user, write # noqa: F401
ROUTES = [('glob', 'fetch_customnode_mappings'), ('legacy', 'fetch_customnode_mappings'),
('legacy', 'fetch_customnode_list'), ('legacy', 'fetch_externalmodel_list')]
@pytest.mark.parametrize('server,name', ROUTES)
def test_a_request_without_mode_is_answered_as_mode_cache(user, registry, server, name): # noqa: F811
configure(user, None, COMFY_ORG)
write(user, f'{server} start')
handler = load_functions(PACKAGE / server / 'manager_server.py', {name}, {
'core': user.cores[server], 'web': web, 'routes': SimpleNamespace(get=route, post=route), 're': re,
'nodes': SimpleNamespace(NODE_CLASS_MAPPINGS={}), 'populate_markdown': lambda row: None,
'check_model_installed': lambda listed: None})[name]
def ask(**query):
return json.loads(asyncio.run(handler(SimpleNamespace(rel_url=SimpleNamespace(query=query)))).text)
assert ask() == ask(mode='cache') != ask(mode='local')