Compare commits

...
1 Commits
Author SHA1 Message Date
ketle-manandClaude Sonnet 4.6 5390f0c94d fix: SSL cert error on CivitAI + Lora Manager UI-to-API conversion
- civitai_service: add _make_ssl_context() that tries certifi first,
  falls back to system store, then CERT_NONE with warning; fixes
  CERTIFICATE_VERIFY_FAILED on Windows Portable Python environments
- comfyui-workflow: convertUiToApi() now detects nodes with
  properties.__lm_widget_ids (Lora Loader (LoraManager)) and maps
  widgets_values via that index, wrapping the loras array as
  {"__value__": [...]} for the API format

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-30 18:18:10 +09:00
4 changed files with 85 additions and 3 deletions
+27
View File
@@ -1,5 +1,32 @@
# DEVLOG - ComfyUI-Workflow-Studio
## 2026-05-30: v0.3.17 — SSL証明書エラー修正・Lora Manager対応
### 概要
2つのバグ修正。CivitAI APIへのリクエストでSSL証明書の検証エラーが発生する問題(Windows Portable Python環境で再現)の修正と、ComfyUI-Lora-ManagerのLoRAローダーノードをGenerateUIタブで正しく変換・生成できるよう対応。
### 変更内容
#### `py/services/civitai_service.py`
- **`_make_ssl_context()`** ヘルパー関数を追加
1. `certifi` がインストールされていればそのCA束を使用
2. `certifi` がなければシステムデフォルトのSSLコンテキストを使用
3. いずれも失敗した場合(Windows Portable Python等でCA束が壊れている環境)は `CERT_NONE` でフォールバック(ログ警告を出力)
- **`_get_ssl_context()`** — モジュールレベルでSSLコンテキストを1回だけ生成してキャッシュ
- `fetch_by_hash()` および `download_image()` の `urlopen` 呼び出しに `context=_get_ssl_context()` を追加
- 修正対象エラー: `SSL: CERTIFICATE_VERIFY_FAILED certificate verify failed: certificate has expired`
#### `static/js/comfyui-workflow.js`
- **`convertUiToApi()`** — Lora Loader (LoraManager) ノードの特殊ウィジェットマッピングを追加
- ノードの `properties.__lm_widget_ids`(LoRA Managerが設定するウィジェット識別子配列)が存在する場合、`widgets_values` をその配列のインデックスで直接マッピング
- `loras` キーの値(UI形式: 配列 `[...]`)をAPI形式 `{"__value__": [...]}` にラップして出力
- 修正前は `object_info` ベースのウィジェットマッピングが LoRA Manager の独自型(非 INT/FLOAT/STRING/BOOLEAN/COMBO)を認識できずスキップされていた
---
## 2026-05-20: v0.3.16 — CivitAIプレビューフォールバック表示
### 概要
+5 -1
View File
@@ -5,7 +5,7 @@ A comprehensive workflow management and generation UI plugin for [ComfyUI](https
Browse, organize, and execute workflows directly from a dedicated studio interface — without switching between windows or manually editing JSON.
![Workflow Studio](https://img.shields.io/badge/ComfyUI-Custom_Node-blue)
![Version](https://img.shields.io/badge/version-0.3.16-green)
![Version](https://img.shields.io/badge/version-0.3.17-green)
## Screenshots
@@ -271,6 +271,10 @@ Click the **camera icon** (next to the W button) in ComfyUI's top bar to capture
## Changelog
### v0.3.17
- **CivitAI SSL fix** — resolved `CERTIFICATE_VERIFY_FAILED` errors when fetching model info on Windows Portable Python environments; uses `certifi` CA bundle when available, falls back to system store, and disables verification only as a last resort with a warning log
- **Lora Manager support** — `Lora Loader (LoraManager)` nodes (ComfyUI-Lora-Manager) are now correctly converted from UI format to API format in the GenerateUI tab; the `loras` widget array is wrapped to `{"__value__": [...]}` as required by the node, enabling generation with LoRA Manager workflows
### v0.3.16
- **CivitAI preview fallback** — model cards and the detail panel's Info tab now display the first CivitAI image directly when no local preview file exists; if the backend download fails (e.g. network restriction server-side), the browser fetches the image URL from the CivitAI cache as a fallback so the preview is always shown after fetching
+37 -2
View File
@@ -3,6 +3,7 @@
import hashlib
import json
import logging
import ssl
from pathlib import Path
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
@@ -11,6 +12,40 @@ from ..config import DATA_DIR
logger = logging.getLogger(__name__)
def _make_ssl_context():
"""Return an SSL context with CA verification.
Tries certifi first (bundled CA store, available in most ComfyUI envs).
Falls back to an unverified context when certifi is absent or the system
store is broken (common with Windows portable Python builds).
"""
try:
import certifi
return ssl.create_default_context(cafile=certifi.where())
except Exception:
pass
try:
ctx = ssl.create_default_context()
return ctx
except Exception:
pass
ctx = ssl.SSLContext(ssl.PROTOCOL_TLS_CLIENT)
ctx.check_hostname = False
ctx.verify_mode = ssl.CERT_NONE
logger.warning("CivitAI: SSL certificate verification disabled (no CA bundle found)")
return ctx
_SSL_CONTEXT = None
def _get_ssl_context():
global _SSL_CONTEXT
if _SSL_CONTEXT is None:
_SSL_CONTEXT = _make_ssl_context()
return _SSL_CONTEXT
CIVITAI_API_BASE = "https://civitai.com/api/v1"
CIVITAI_CACHE_FILE = DATA_DIR / "civitai_cache.json"
@@ -77,7 +112,7 @@ class CivitaiService:
url = f"{CIVITAI_API_BASE}/model-versions/by-hash/{sha256_hash}"
try:
req = Request(url, headers={"User-Agent": "ComfyUI-Workflow-Studio/1.0"})
with urlopen(req, timeout=15) as resp:
with urlopen(req, timeout=15, context=_get_ssl_context()) as resp:
data = json.loads(resp.read().decode("utf-8"))
if not data or "id" not in data:
@@ -201,7 +236,7 @@ class CivitaiService:
"""Download an image from URL and save to save_path. Returns True on success."""
try:
req = Request(url, headers={"User-Agent": "ComfyUI-Workflow-Studio/1.0"})
with urlopen(req, timeout=timeout) as resp:
with urlopen(req, timeout=timeout, context=_get_ssl_context()) as resp:
data = resp.read()
with open(save_path, "wb") as f:
f.write(data)
+16
View File
@@ -305,6 +305,21 @@ export const comfyWorkflow = {
// 2. Map widgets_values to widget input names using object_info
const widgets = node.widgets_values || [];
if (widgets.length > 0) {
// Lora Loader (LoraManager): use __lm_widget_ids from node properties
// widgets_values: [autocomplete_meta_obj, text_str, loras_array]
// API format: {__lm_autocomplete_meta_text: obj, text: str, loras: {__value__: arr}}
const lmWidgetIds = node.properties?.__lm_widget_ids;
if (lmWidgetIds && Array.isArray(lmWidgetIds)) {
lmWidgetIds.forEach((name, idx) => {
if (idx >= widgets.length || linkedInputNames.has(name)) return;
let val = widgets[idx];
if (name === "loras" && Array.isArray(val)) {
val = { "__value__": val };
}
inputs[name] = val;
});
} else {
const widgetNames = _getWidgetInputNames(objectInfo, node.type);
if (widgetNames.length > 0) {
@@ -374,6 +389,7 @@ export const comfyWorkflow = {
});
}
}
} // end else (non-LoraManager path)
}
api[nodeId] = {