[PR #3390] fix: resolve the default channel from channels.list in get_risky_level / 修复:get_risky_level 改为从 channels.list 解析 default 通道 #3259

Open
opened 2026-10-28 21:16:32 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Comfy-Org/ComfyUI-Manager/pull/3390
Author: @self-exiler
Created: 10/18/2026
Status: 🔄 Open

Base: main ← Head: fix/risky-level-channel-from-channel-list


📝 Commits (5)

  • 87cb312 fix: resolve the default channel from channels.list in get_risky_level
  • c419b07 warn when the resolved default channel uses plain HTTP
  • 1565db5 gate plain-HTTP default channels on http_channel_enabled
  • 7bbe1eb make the plain-HTTP scheme check case-insensitive
  • 40a4cc1 normalize mixed-case http scheme before returning the default channel

📊 Changes

3 files changed (+277 additions, -1 deletions)

View changed files

📝 glob/manager_core.py (+51 -0)
📝 glob/manager_server.py (+1 -1)
➕ tests/test_default_channel_resolution.py (+225 -0)

📄 Description

Summary / 摘要

EN: get_risky_level() in glob/manager_server.py passed the literal URL https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main when fetching the default channel's custom-node-list.json for the pre-install risk check. That request bypassed channels.list and config.ini entirely: users running the manager behind a mirror or proxy (mirror-prefixed channel entries, custom forks) still hit the upstream host on every install, and when that request failed the risk check silently lost the default half of its data set (which can misclassify installable node packs as high risk under security_level = normal).

This PR adds core.get_default_channel_url() and uses it in get_risky_level(). The URL is resolved in this order:

  1. the default entry of channels.list
  2. config.ini's channel_url (the channel used when a request does not name one — keeps custom-fork setups working when default was removed from channels.list)
  3. DEFAULT_CHANNEL (upstream) — i.e. the exact legacy hardcoded behavior

Reading channels.list may fail (permissions, malformed file); such failures degrade to the next fallback instead of breaking the install path. With an unmodified setup the resolved URL is identical to the old hardcoded one, so behavior is unchanged unless the user has customized their channels.

中文:glob/manager_server.py 的 get_risky_level() 在安装节点前获取 default 通道的 custom-node-list.json 做风险判定时,硬编码了 https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main。该请求完全不经过 channels.list 与 config.ini:使用镜像/代理(镜像前缀通道、自建 fork)的用户每次安装仍会直连上游;请求失败时风险判定会静默丢失 default 通道这一半数据(在 security_level = normal 下可能把本可安装的节点判为 high 而拦截)。

本 PR 新增 core.get_default_channel_url() 并在 get_risky_level() 中使用,解析顺序为:

  1. channels.list 的 default 条目
  2. config.ini 的 channel_url(未显式指定通道时的默认通道——当用户从 channels.list 移除了 default 行时,自建 fork 场景仍可工作)
  3. DEFAULT_CHANNEL(上游)——即原有硬编码行为

读取 channels.list 失败(权限、文件损坏等)时降级到下一级兜底,不会破坏安装流程。未做任何自定义的环境下解析结果与旧硬编码值完全一致,行为不变。

Changes / 改动

  • glob/manager_core.py: new get_default_channel_url() resolver / 新增 get_default_channel_url() 解析函数
  • glob/manager_server.py: get_risky_level() now consumes the resolver / get_risky_level() 改为使用该解析函数
  • tests/test_default_channel_resolution.py: resolution-order cases + AST wiring guards (following the test_install_flag_predicate.py harness precedent, no new dependencies) / 解析顺序用例 + AST 接线守卫(沿用 test_install_flag_predicate.py 的测试范式,无新增依赖)

Testing / 测试

  • python -m unittest tests.test_default_channel_resolution — 13 tests pass / 13 条用例全部通过
  • Cases: mirror-prefixed default, custom fork, trailing-slash trim, default missing → config.ini channel_url, both missing → DEFAULT_CHANNEL, empty channel_url, unreadable channels.list (degrades, no raise), plus static guards that get_risky_level calls the resolver and no raw.githubusercontent.com literal remains in manager_server.py.
  • 用例覆盖:镜像前缀 default、自定义 fork、尾斜杠裁剪、缺 default 行回退 config.ini、两者皆缺回退上游、空 channel_url、channels.list 不可读(降级不抛异常),以及静态守卫(get_risky_level 调用解析函数、manager_server.py 中不再有 raw 硬编码字面量)。

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Comfy-Org/ComfyUI-Manager/pull/3390 **Author:** [@self-exiler](https://github.com/self-exiler) **Created:** 10/18/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/risky-level-channel-from-channel-list` --- ### 📝 Commits (5) - [`87cb312`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/87cb312204f0d4acca9322262d1ce88ce32902a2) fix: resolve the default channel from channels.list in get_risky_level - [`c419b07`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/c419b07497c460c11b1351897bd4769ef33747ac) warn when the resolved default channel uses plain HTTP - [`1565db5`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/1565db53b55a534a20ad759e772e6a39d12307b9) gate plain-HTTP default channels on http_channel_enabled - [`7bbe1eb`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/7bbe1eb1aca426c1cf971c33ff9f2fa2901f7e4d) make the plain-HTTP scheme check case-insensitive - [`40a4cc1`](https://github.com/Comfy-Org/ComfyUI-Manager/commit/40a4cc107d60a562ba523810c8546516fa6f974a) normalize mixed-case http scheme before returning the default channel ### 📊 Changes **3 files changed** (+277 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `glob/manager_core.py` (+51 -0) 📝 `glob/manager_server.py` (+1 -1) ➕ `tests/test_default_channel_resolution.py` (+225 -0) </details> ### 📄 Description ## Summary / 摘要 **EN**: `get_risky_level()` in `glob/manager_server.py` passed the literal URL `https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main` when fetching the `default` channel's `custom-node-list.json` for the pre-install risk check. That request bypassed `channels.list` and `config.ini` entirely: users running the manager behind a mirror or proxy (mirror-prefixed channel entries, custom forks) still hit the upstream host on every install, and when that request failed the risk check silently lost the `default` half of its data set (which can misclassify installable node packs as `high` risk under `security_level = normal`). This PR adds `core.get_default_channel_url()` and uses it in `get_risky_level()`. The URL is resolved in this order: 1. the `default` entry of `channels.list` 2. `config.ini`'s `channel_url` (the channel used when a request does not name one — keeps custom-fork setups working when `default` was removed from `channels.list`) 3. `DEFAULT_CHANNEL` (upstream) — i.e. the exact legacy hardcoded behavior Reading `channels.list` may fail (permissions, malformed file); such failures degrade to the next fallback instead of breaking the install path. With an unmodified setup the resolved URL is identical to the old hardcoded one, so behavior is unchanged unless the user has customized their channels. **中文**:`glob/manager_server.py` 的 `get_risky_level()` 在安装节点前获取 `default` 通道的 `custom-node-list.json` 做风险判定时,硬编码了 `https://raw.githubusercontent.com/ltdrdata/ComfyUI-Manager/main`。该请求完全不经过 `channels.list` 与 `config.ini`:使用镜像/代理(镜像前缀通道、自建 fork)的用户每次安装仍会直连上游;请求失败时风险判定会静默丢失 default 通道这一半数据(在 `security_level = normal` 下可能把本可安装的节点判为 `high` 而拦截)。 本 PR 新增 `core.get_default_channel_url()` 并在 `get_risky_level()` 中使用,解析顺序为: 1. `channels.list` 的 `default` 条目 2. `config.ini` 的 `channel_url`(未显式指定通道时的默认通道——当用户从 `channels.list` 移除了 `default` 行时,自建 fork 场景仍可工作) 3. `DEFAULT_CHANNEL`(上游)——即原有硬编码行为 读取 `channels.list` 失败(权限、文件损坏等)时降级到下一级兜底,不会破坏安装流程。未做任何自定义的环境下解析结果与旧硬编码值完全一致,行为不变。 ## Changes / 改动 - `glob/manager_core.py`: new `get_default_channel_url()` resolver / 新增 `get_default_channel_url()` 解析函数 - `glob/manager_server.py`: `get_risky_level()` now consumes the resolver / `get_risky_level()` 改为使用该解析函数 - `tests/test_default_channel_resolution.py`: resolution-order cases + AST wiring guards (following the `test_install_flag_predicate.py` harness precedent, no new dependencies) / 解析顺序用例 + AST 接线守卫(沿用 `test_install_flag_predicate.py` 的测试范式,无新增依赖) ## Testing / 测试 - `python -m unittest tests.test_default_channel_resolution` — 13 tests pass / 13 条用例全部通过 - Cases: mirror-prefixed `default`, custom fork, trailing-slash trim, `default` missing → `config.ini channel_url`, both missing → `DEFAULT_CHANNEL`, empty `channel_url`, unreadable `channels.list` (degrades, no raise), plus static guards that `get_risky_level` calls the resolver and no `raw.githubusercontent.com` literal remains in `manager_server.py`. - 用例覆盖:镜像前缀 default、自定义 fork、尾斜杠裁剪、缺 `default` 行回退 `config.ini`、两者皆缺回退上游、空 `channel_url`、`channels.list` 不可读(降级不抛异常),以及静态守卫(`get_risky_level` 调用解析函数、`manager_server.py` 中不再有 raw 硬编码字面量)。 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#3259
No description provided.