fix: surface schema load errors and normalize update_server inputs (#41)

- registry.py: replace bare `except Exception: pass` with specific
  exception handling and a warning log, so corrupted schema.json files
  are visible instead of silently disappearing from workflow list
- services.py: apply the same input normalization in update_server as
  add_server (strip whitespace, coerce types, apply fallback defaults)
  to prevent dirty data from entering config

Co-authored-by: Kelin <kelin@KelindeMacBook-Air.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
科林 KELIN
2026-03-19 14:43:00 +08:00
committed by GitHub
co-authored by Kelin Claude Sonnet 4.6
parent ca27560ed7
commit ffbdd76b52
2 changed files with 16 additions and 6 deletions
+6 -3
View File
@@ -1,13 +1,16 @@
import os
import json
import argparse
import sys
from logging import getLogger
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from shared.config import get_server_schema_path, list_server_workflow_dirs
from shared.runtime_config import get_runtime_config
logger = getLogger(__name__)
def get_workflows(is_agent=False):
config = get_runtime_config()
@@ -71,8 +74,8 @@ def get_workflows(is_agent=False):
}
all_workflows.append(workflow_info)
except Exception:
pass
except (json.JSONDecodeError, OSError) as e:
logger.warning("Skipping workflow '%s/%s': %s", server_id, workflow_id, e)
if is_agent:
# Clean internal fields
+10 -3
View File
@@ -123,9 +123,16 @@ class UIStorageService:
config = self.get_config()
for s in config.get("servers", []):
if s.get("id") == server_id:
for key in ("name", "url", "auth", "enabled", "output_dir"):
if key in updates:
s[key] = updates[key]
if "name" in updates:
s["name"] = str(updates["name"] or "").strip() or server_id
if "url" in updates:
s["url"] = str(updates["url"] or "").strip()
if "auth" in updates:
s["auth"] = str(updates["auth"] or "").strip()
if "enabled" in updates:
s["enabled"] = bool(updates["enabled"])
if "output_dir" in updates:
s["output_dir"] = str(updates["output_dir"] or "./outputs").strip() or "./outputs"
self.save_config(config)
return self._serialize_server_for_ui(s)
raise FileNotFoundError(f"Server '{server_id}' not found")