From 95e73a6275bdca702f57474a9196d71aa61f0a23 Mon Sep 17 00:00:00 2001 From: Kelin Date: Mon, 30 Mar 2026 00:25:00 +0800 Subject: [PATCH] fix: use safe .get() for 'mode' query param in fetch_customnode_list The `/customnode/getlist` endpoint crashes with `KeyError: 'mode'` when the `mode` query parameter is missing from the request. Extract the mode value once using `.get()` with a default fallback, consistent with how `skip_update` is already handled on the same endpoint. Fixes #2740 Co-Authored-By: Claude Opus 4.6 (1M context) --- glob/manager_server.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/glob/manager_server.py b/glob/manager_server.py index eff7c032..85c668d0 100644 --- a/glob/manager_server.py +++ b/glob/manager_server.py @@ -874,14 +874,16 @@ async def fetch_customnode_list(request): else: skip_update = False - 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)