fix(skills): widen BOM-tolerant reads to all comfyui workflow-JSON call paths

The salvaged fix covered run_workflow.py and hardware_check.py. The same
locale-default read of user-authored workflow JSON exists in five sibling
scripts (auto_fix_deps, check_deps, extract_schema, health_check,
run_batch) — same bug class, same utf-8-sig fix. Invariant test extended
to pin all nine read sites.

The pdf half of the original PR is superseded: those scripts were
replaced wholesale by the clean-room rewrite (#81890), which ships
UTF-8-explicit I/O enforced by its own invariant test.
This commit is contained in:
Teknium
2026-08-08 11:13:49 -07:00
parent 50f742f8ed
commit 36f73df139
7 changed files with 13 additions and 5 deletions
@@ -0,0 +1 @@
CrazyWillBear
@@ -102,7 +102,7 @@ def main(argv: list[str] | None = None) -> int:
emit_json({"error": f"Workflow not found: {args.workflow}"})
return 1
try:
with wf_path.open() as f:
with wf_path.open(encoding="utf-8-sig") as f:
workflow = unwrap_workflow(json.load(f))
except (ValueError, json.JSONDecodeError) as e:
emit_json({"error": str(e)})
@@ -408,7 +408,7 @@ def main(argv: list[str] | None = None) -> int:
emit_json({"error": f"Workflow file not found: {args.workflow}"})
return 1
try:
with wf_path.open() as f:
with wf_path.open(encoding="utf-8-sig") as f:
payload = json.load(f)
workflow = unwrap_workflow(payload)
except ValueError as e:
@@ -285,7 +285,7 @@ def main(argv: list[str] | None = None) -> int:
return 1
try:
with wf_path.open() as f:
with wf_path.open(encoding="utf-8-sig") as f:
payload = json.load(f)
workflow = unwrap_workflow(payload)
except ValueError as e:
@@ -163,7 +163,7 @@ def main(argv: list[str] | None = None) -> int:
workflow_check = {"error": "workflow file not found"}
else:
try:
with wf_path.open() as f:
with wf_path.open(encoding="utf-8-sig") as f:
workflow = unwrap_workflow(json.load(f))
from check_deps import check_deps
workflow_check = check_deps(workflow, host=args.host, api_key=api_key)
+1 -1
View File
@@ -157,7 +157,7 @@ def main(argv: list[str] | None = None) -> int:
emit_json({"error": f"Workflow not found: {args.workflow}"})
return 1
try:
with wf_path.open() as f:
with wf_path.open(encoding="utf-8-sig") as f:
workflow = unwrap_workflow(json.load(f))
except (ValueError, json.JSONDecodeError) as e:
emit_json({"error": str(e)})
+7
View File
@@ -28,6 +28,13 @@ _ENCODING_SENSITIVE_READS = [
("hardware_check.py", 'with open("/proc/meminfo", "r", encoding="utf-8") as fh:'),
("run_workflow.py", 'with open(schema_path, encoding="utf-8-sig") as f:'),
("run_workflow.py", 'with wf_path.open(encoding="utf-8-sig") as f:'),
# Sibling call paths: every other script that parses a user-authored
# workflow JSON reads it the same BOM-tolerant way (same bug class).
("auto_fix_deps.py", 'wf_path.open(encoding="utf-8-sig")'),
("check_deps.py", 'wf_path.open(encoding="utf-8-sig")'),
("extract_schema.py", 'wf_path.open(encoding="utf-8-sig")'),
("health_check.py", 'wf_path.open(encoding="utf-8-sig")'),
("run_batch.py", 'wf_path.open(encoding="utf-8-sig")'),
]