From 8a89ba42b65eb647e1d8f7cd7819d5f59795cbde Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Tue, 20 Oct 2026 17:53:45 -0700 Subject: [PATCH 1/9] fix(workflow): persist Cloud sidebar files and verify save identity --- CHANGELOG.md | 17 + comfy_cli/command/workflow.py | 389 ++++++++++--- comfy_cli/error_codes.py | 39 +- comfy_cli/skills/comfy/SKILL.md | 18 +- .../command/test_pretty_print_sanitize.py | 28 + .../comfy_cli/command/test_workflow_saved.py | 538 +++++++++++++++++- 6 files changed, 912 insertions(+), 117 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3bbf3db5e..f5a999c84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -170,6 +170,23 @@ history. already finished. Neither old key is published any more. The second exit was also skipping the trimming and redaction that key drives, so it emitted the full traceback and a `current_inputs` that can hold an api_key. +- `comfy workflow save --where cloud` saves the workflow where the Cloud + Workflows sidebar lists it, as `workflows/.json`, so it shows there and + opens from it. It used to create only an `/api/workflows` record, which the + sidebar never shows. Cloud keeps a record for the file, and `workflow_id` and + `latest_version` are read back from it by name; when exactly one record by + that name with matching content can't be read back they are null, with a + `workflow_record_unresolved` warning, and the save still succeeds. `--json` + also carries `filename`, `size` and `modified`. A same-name save replaces the + workflow, as the Cloud editor's Save does, where it used to add a second + record with the same name; the new `--no-overwrite` refuses it with + `workflow_exists` instead, on both routes. On Cloud `--description` is now + ignored with a `description_ignored` warning, since the file has no + description field. A save named `.index.json`, the folder's favorites file, + is refused, as are Cloud dotfiles or hidden folders that the sidebar never + lists. Cloud deletion now removes the sidebar file as well as its record; + ambiguous same-name records are refused before deletion, and partial cleanup + reports `workflow_delete_incomplete` with the file's deletion state. - `comfy workflow validate` (and `comfy run`'s pre-submit check) accepts a literal the server converts before checking it: an integer string on an INT input (`"1536"`), a numeric string on a FLOAT input, a number on a STRING diff --git a/comfy_cli/command/workflow.py b/comfy_cli/command/workflow.py index d4594a65d..37cc1f7a8 100644 --- a/comfy_cli/command/workflow.py +++ b/comfy_cli/command/workflow.py @@ -793,6 +793,14 @@ def print_cmd( # ``flux.json`` or ``sub/dir/flux.json``) — that same string is what # ``get``/``delete`` take and what ``save`` returns. # +# ``save`` writes a ``/userdata`` file on BOTH routes. On cloud that file is what +# the Workflows sidebar lists: a record made only through ``POST /api/workflows`` +# has no file behind it and never shows there. Cloud's userdata POST mirrors the +# file into the ``/api/workflows`` store itself (a record named after the file, +# ``workflows/My Flow.json`` → ``My Flow``), so ``save`` writes the file only and +# reads the record id back by that exact name. ``list``/``get``/``delete`` still +# address the record store. +# # The two paths share the ``--json`` envelope shape as far as feasible; the # per-verb docstrings + PR note the deltas (local has no versioning, no # server-side description, and reports raw file ``size``/``modified``/``created`` @@ -802,6 +810,14 @@ def print_cmd( # The userdata subdirectory the ComfyUI frontend stores saved workflows in. _WORKFLOWS_DIR = "workflows" +# The frontend keeps its favorites list in this file inside ``workflows/``. A save +# under that name would replace the user's bookmarks rather than add a workflow. +_WORKFLOWS_INDEX_FILE = ".index.json" + +# Rows per ``/api/workflows`` page when ``save`` reads back the record Cloud made +# for the file. A full page may be truncated, so it resolves nothing. +_RECORD_LOOKUP_LIMIT = 100 + # Cap on a single ``/userdata`` response we buffer into memory. We read one byte # past the cap so we can *detect* truncation and fail loudly, rather than # silently writing a partial workflow and reporting success. @@ -941,7 +957,7 @@ def _reject_unsafe_workflow_key(renderer, key: str) -> str: ): renderer.error( code="invalid_argument", - message=f"workflow id {key!r} is not a valid path under the local workflows/ dir", + message=f"workflow id {key!r} is not a valid path under the workflows/ dir", hint="use a relative name like `flux.json` or `sub/flux.json` (no `..`, no leading `/`)", ) raise typer.Exit(code=1) @@ -1256,9 +1272,8 @@ def _local_get(renderer, target, workflow_id: str, out: str | None) -> None: renderer.emit(payload, command="workflow get", where="local") -def _local_save(renderer, target, workflow_file: str, name: str, description: str | None) -> None: - import urllib.error - +def _read_workflow_for_save(renderer, workflow_file: str) -> tuple[Path, str, dict]: + """Read and parse the workflow file ``save`` uploads: ``(path, text, parsed)``.""" path = Path(workflow_file).expanduser() if not path.is_file(): renderer.error( @@ -1292,15 +1307,67 @@ def _local_save(renderer, target, workflow_file: str, name: str, description: st hint="use ComfyUI's `File > Save` to export", ) raise typer.Exit(code=1) + return path, text, workflow_json + + +def _saved_workflow_key(renderer, name: str, *, ext_case_sensitive: bool) -> str: + """The file ``save`` writes under ``workflows/`` for ``--name``. + + ``.json`` is appended unless the name already ends in it. Cloud creates a + workflow record only for a file ending in a lowercase ``.json``, so the cloud + route matches the extension case-sensitively (``Flow.JSON`` → ``Flow.JSON.json``); + the local route keeps its case-insensitive match. + """ + has_ext = name.endswith(".json") if ext_case_sensitive else name.lower().endswith(".json") + key = _reject_unsafe_workflow_key(renderer, name if has_ext else f"{name}.json") + if ext_case_sensitive and any(part.startswith(".") for part in key.split("/")): + renderer.error( + code="invalid_argument", + message=f"{key!r} is hidden from the Cloud Workflows sidebar", + hint="use a name with no dot-prefixed file or folder components", + ) + raise typer.Exit(code=1) + if key.rsplit("/", 1)[-1] == _WORKFLOWS_INDEX_FILE: + renderer.error( + code="invalid_argument", + message=f"{key!r} is the workflows/ folder's favorites index, not a workflow name", + hint="pass a different `--name`", + ) + raise typer.Exit(code=1) + return key + + +def _workflow_exists_error(renderer, key: str) -> typer.Exit: + renderer.error( + code="workflow_exists", + message=f"a saved workflow named {key!r} already exists; --no-overwrite left it unchanged", + hint="pass a different `--name`, or drop `--no-overwrite` to replace it", + details={"filename": key}, + ) + return typer.Exit(code=1) + + +def _overwrite_query(overwrite: bool) -> dict: + return {"overwrite": "true" if overwrite else "false", "full_info": "true"} - key = name if name.lower().endswith(".json") else f"{name}.json" - key = _reject_unsafe_workflow_key(renderer, key) - url = _userdata_file_url(target, key, query={"overwrite": "true", "full_info": "true"}) + +def _local_save( + renderer, target, workflow_file: str, name: str, description: str | None, *, overwrite: bool = True +) -> None: + import urllib.error + + path, text, _workflow_json = _read_workflow_for_save(renderer, workflow_file) + key = _saved_workflow_key(renderer, name, ext_case_sensitive=False) + url = _userdata_file_url(target, key, query=_overwrite_query(overwrite)) try: _, raw = _userdata_request( url, target, method="POST", data=text.encode("utf-8"), content_type="application/json" ) - except (urllib.error.HTTPError, urllib.error.URLError, OSError, _ResponseTooLarge) as e: + except urllib.error.HTTPError as e: + if e.code == 409: + raise _workflow_exists_error(renderer, key) from e + raise _handle_local_http_error(renderer, e, operation="save", workflow_id=key) from e + except (urllib.error.URLError, OSError, _ResponseTooLarge) as e: raise _handle_local_http_error(renderer, e, operation="save", workflow_id=key) from e info = None @@ -1329,10 +1396,125 @@ def _local_save(renderer, target, workflow_file: str, name: str, description: st {"code": "description_ignored", "message": "--description is ignored on the local path (no metadata store)"} ] if renderer.is_pretty(): - rprint(f"[green]✓[/green] saved [dim]{stored_id}[/dim]") + rprint(f"[green]✓[/green] saved [dim]{sanitize_markup(stored_id)}[/dim]") renderer.emit(payload, command="workflow save", where="local", changed=True) +def _cloud_record_name(key: str) -> str | None: + """The name Cloud gives the record it mirrors from ``workflows/``. + + Cloud drops ``.json`` and cleans the path (``sub/.json`` → ``sub``); an empty + or dot-only result gets no record. ``key`` has passed ``_saved_workflow_key``, + so it ends in ``.json`` and carries no ``..`` segment. + """ + import posixpath + + stem = key[: -len(".json")] + name = posixpath.normpath(stem) if stem else "" + return None if name in ("", ".", "..") else name + + +def _find_mirrored_record(target, record_name: str, workflow_json: dict | None = None) -> dict | None: + """The one ``/api/workflows`` record named exactly ``record_name``, else ``None``. + + Best-effort: the file is already saved when this runs, so a failed or + ambiguous read must not fail the save. Cloud's ``name`` filter is a + case-insensitive substring match, so the exact compare happens here; two + records under one name (``/api/workflows`` allows that) or a page that may be + truncated resolve nothing rather than a guess. + """ + import urllib.error + import urllib.parse + + query = urllib.parse.urlencode({"limit": _RECORD_LOOKUP_LIMIT, "name": record_name}) + try: + _, body = _http_request(target.url("workflows") + "?" + query, target) + except (urllib.error.URLError, OSError, _ResponseUnparseable, _ResponseTooLarge): + return None + rows = body.get("data") if isinstance(body, dict) else None + if not isinstance(rows, list) or len(rows) >= _RECORD_LOOKUP_LIMIT: + return None + matches = [r for r in rows if isinstance(r, dict) and r.get("name") == record_name] + if len(matches) != 1 or not isinstance(matches[0].get("id"), str) or not matches[0]["id"]: + return None + record = matches[0] + if workflow_json is not None: + # SyncFromUserdata is best-effort: an old record may still exist after + # its update failed. Do not hand out an id whose `get` returns stale data. + try: + _, content = _http_request( + target.url("workflows", urllib.parse.quote(record["id"], safe=""), "content"), target + ) + except (urllib.error.URLError, OSError, _ResponseUnparseable, _ResponseTooLarge): + return None + if not isinstance(content, dict) or content.get("workflow_json") != workflow_json: + return None + return record + + +def _cloud_save( + renderer, target, workflow_file: str, name: str, description: str | None, *, overwrite: bool = True +) -> None: + import urllib.error + + path, _text, workflow_json = _read_workflow_for_save(renderer, workflow_file) + key = _saved_workflow_key(renderer, name, ext_case_sensitive=True) + # The Cloud frontend's own save: the graph JSON as the body of a userdata + # write under workflows/. This file is what the Workflows sidebar lists. + url = _userdata_file_url(target, key, query=_overwrite_query(overwrite)) + try: + _, info = _http_request(url, target, method="POST", body=workflow_json) + except urllib.error.HTTPError as e: + if e.code == 409: + raise _workflow_exists_error(renderer, key) from e + raise _handle_cloud_http_error(renderer, e, operation="save") from e + except (urllib.error.URLError, OSError, _ResponseUnparseable, _ResponseTooLarge) as e: + raise _handle_cloud_http_error(renderer, e, operation="save") from e + + record_name = _cloud_record_name(key) + record = _find_mirrored_record(target, record_name, workflow_json) if record_name else None + latest = record.get("latest_version") if record else None + payload: dict[str, Any] = { + "workflow_id": record["id"] if record else None, + "name": record_name or key, + "filename": key, + "latest_version": latest if isinstance(latest, int) and not isinstance(latest, bool) else None, + "source": str(path), + "size": info.get("size") if isinstance(info, dict) else None, + "modified": info.get("modified") if isinstance(info, dict) else None, + } + warnings: list[dict[str, str]] = [] + if description: + warnings.append( + { + "code": "description_ignored", + "message": "--description is ignored: the Cloud Workflows sidebar file has no description field", + } + ) + if record is None: + warnings.append( + { + "code": "workflow_record_unresolved", + "message": f"saved {key!r} to the Workflows sidebar, but no single Cloud workflow record named " + f"{record_name!r} with matching content could be read back, so workflow_id is null; " + "open the file from the sidebar and inspect `comfy --json workflow list --name `; " + "do not repeat the save", + } + ) + if warnings: + payload["warnings"] = warnings + if renderer.is_pretty(): + shown = sanitize_markup(f"{_WORKFLOWS_DIR}/{key}") + rprint( + f"[green]✓[/green] saved to the Cloud Workflows sidebar as [bold]{shown}[/bold]" + + (f" → [dim]{sanitize_markup(record['id'])}[/dim]" if record else "") + ) + rprint("[dim]refresh an open Comfy Cloud tab to see it in the sidebar[/dim]") + for w in warnings: + rprint(f"[yellow]![/yellow] {sanitize_markup(w['message'])}") + renderer.emit(payload, command="workflow save", where="cloud", changed=True) + + def _local_delete(renderer, target, workflow_id: str) -> None: import urllib.error @@ -1349,6 +1531,93 @@ def _local_delete(renderer, target, workflow_id: str) -> None: renderer.emit(payload, command="workflow delete", where="local", changed=True) +def _cloud_delete(renderer, target, workflow_id: str) -> None: + """Delete the sidebar file and record; the record API alone leaves the file. + + Cloud's userdata delete also deletes a same-name record best-effort. Finish + that cleanup explicitly, accepting a 404 only after the file was removed. + Legacy record-only workflows still delete through the record endpoint. + """ + import urllib.error + import urllib.parse + + url = target.url("workflows", urllib.parse.quote(workflow_id, safe="")) + file_deleted = False + key = None + try: + _, record = _http_request(url, target) + if not isinstance(record, dict): + raise _ResponseUnparseable() + name = record.get("name") + if isinstance(name, str) and name: + key = _reject_unsafe_workflow_key(renderer, f"{name}.json") + if key != f"{name}.json": + renderer.error( + code="workflow_filename_ambiguous", + message="the record name would be normalized to a different sidebar filename", + hint="inspect and remove the intended file in the Cloud sidebar before deleting its record", + details={"workflow_id": workflow_id, "filename": key}, + ) + raise typer.Exit(code=1) + if key.rsplit("/", 1)[-1] == _WORKFLOWS_INDEX_FILE: + renderer.error( + code="invalid_argument", + message="refusing to delete the workflows favorites index", + hint="delete this record directly through the Cloud workflow API", + ) + raise typer.Exit(code=1) + file_url = _userdata_file_url(target, key) + try: + _, file_content = _http_request(file_url, target) + except urllib.error.HTTPError as e: + if e.code != 404: + raise + else: + # Userdata belongs to the current user, but workflow reads are + # workspace-wide and a best-effort sync may leave stale content. + # A unique name alone cannot associate this file with the record. + mirror = _find_mirrored_record(target, name, file_content) if isinstance(file_content, dict) else None + owner_matches = False + if mirror is not None and mirror["id"] == workflow_id: + _, user = _http_request(target.url("user"), target) + user_id = user.get("id") if isinstance(user, dict) else None + owner_matches = isinstance(user_id, str) and bool(user_id) and record.get("created_by") == user_id + if not owner_matches: + renderer.error( + code="workflow_filename_ambiguous", + message=f"cannot safely associate sidebar file {key!r} with record {workflow_id!r}", + hint="inspect same-name records with `comfy --json workflow list --name `; " + "remove the intended file in the Cloud sidebar before deleting its record", + details={"workflow_id": workflow_id, "filename": key}, + ) + raise typer.Exit(code=1) + _http_request(file_url, target, method="DELETE") + file_deleted = True + try: + _http_request(url, target, method="DELETE") + except urllib.error.HTTPError as e: + if e.code != 404 or not file_deleted: + raise + except (urllib.error.URLError, OSError, _ResponseUnparseable, _ResponseTooLarge) as e: + if file_deleted: + renderer.error( + code="workflow_delete_incomplete", + message="the sidebar file was deleted, but workflow record cleanup could not be confirmed", + hint=f"check `comfy --json workflow list`, then retry `comfy workflow delete {workflow_id}` " + "if that record remains", + details={"workflow_id": workflow_id, "filename": key, "file_deleted": True}, + ) + raise typer.Exit(code=1) from e + raise _handle_cloud_http_error(renderer, e, operation="delete", workflow_id=workflow_id) from e + + payload = {"workflow_id": workflow_id, "deleted": True} + if file_deleted: + payload["filename"] = key + if renderer.is_pretty(): + rprint(f"[green]✓[/green] deleted [dim]{sanitize_markup(workflow_id)}[/dim]") + renderer.emit(payload, command="workflow delete", where="cloud", changed=True) + + @app.command("list", help="List saved workflows (cloud store, or local ComfyUI /userdata with --where local).") @tracking.track_command("workflow") def list_cmd( @@ -1555,7 +1824,12 @@ def get_cmd( @app.command( "save", - help="Save a workflow JSON to the saved-workflow store (cloud, or local ComfyUI /userdata with --where local).", + help=( + "Save a workflow JSON as workflows/.json. On Comfy Cloud it appears in the Workflows sidebar " + "(refresh an open tab) and opens from there; Cloud also keeps a workflow record for it, returned as " + "workflow_id. With --where local it lands in the local ComfyUI's /userdata workflows/ folder. " + "A save under an existing name replaces it unless --no-overwrite." + ), ) @tracking.track_command("workflow") def save_cmd( @@ -1563,72 +1837,34 @@ def save_cmd( name: Annotated[ str, typer.Option( - "--name", help="Cloud: display name. Local: filename under workflows/ ('.json' appended if absent)." + "--name", + help="Filename under workflows/ ('.json' appended if absent; subfolders like team/flux allowed). " + "On Cloud it is also the sidebar entry and the workflow record's name.", ), ], description: Annotated[ str | None, - typer.Option("--description", show_default=False, help="Optional description (cloud only; ignored on local)."), + typer.Option( + "--description", + show_default=False, + help="Ignored, with a description_ignored warning: the saved workflow file has no description field.", + ), ] = None, + overwrite: Annotated[ + bool, + typer.Option( + "--overwrite/--no-overwrite", + help="Replace a saved workflow of the same name (default). --no-overwrite refuses with " + "workflow_exists instead.", + ), + ] = True, where: Annotated[str | None, typer.Option("--where", show_default=False)] = None, ): - import urllib.error - renderer = get_renderer() target = _resolve_where_target(where) if not target.is_cloud: - return _local_save(renderer, target, workflow_file, name, description) - - path = Path(workflow_file).expanduser() - if not path.is_file(): - renderer.error( - code="workflow_not_found", - message=f"local workflow file not found: {path}", - hint="check the path", - ) - raise typer.Exit(code=1) - try: - workflow_json = json.loads(path.read_text(encoding="utf-8")) - except json.JSONDecodeError as e: - renderer.error( - code="workflow_invalid_json", - message=f"{path} is not valid JSON: {e}", - hint="re-export the workflow from ComfyUI", - ) - raise typer.Exit(code=1) from e - if not isinstance(workflow_json, dict): - renderer.error( - code="workflow_not_api_format", - message="workflow_json must be a JSON object", - hint="use ComfyUI's `File > Save` to export", - ) - raise typer.Exit(code=1) - - body: dict[str, Any] = {"name": name, "workflow_json": workflow_json} - if description: - body["description"] = description - url = target.url("workflows") - try: - _, resp = _http_request(url, target, method="POST", body=body) - except ( - urllib.error.HTTPError, - urllib.error.URLError, - OSError, - _ResponseUnparseable, - _ResponseTooLarge, - ) as e: - raise _handle_cloud_http_error(renderer, e, operation="save") from e - - workflow_id = (resp or {}).get("id") if isinstance(resp, dict) else None - payload = { - "workflow_id": workflow_id, - "name": name, - "latest_version": (resp or {}).get("latest_version") if isinstance(resp, dict) else None, - "source": str(path), - } - if renderer.is_pretty(): - rprint(f"[green]✓[/green] saved {name!r} → [dim]{workflow_id}[/dim]") - renderer.emit(payload, command="workflow save", where="cloud", changed=True) + return _local_save(renderer, target, workflow_file, name, description, overwrite=overwrite) + return _cloud_save(renderer, target, workflow_file, name, description, overwrite=overwrite) @app.command("delete", help="Delete a saved workflow (cloud, or local ComfyUI /userdata with --where local).") @@ -1640,31 +1876,12 @@ def delete_cmd( ], where: Annotated[str | None, typer.Option("--where", show_default=False)] = None, ): - import urllib.error - renderer = get_renderer() target = _resolve_where_target(where) if not target.is_cloud: return _local_delete(renderer, target, workflow_id) - import urllib.parse as _up - - url = target.url("workflows", _up.quote(workflow_id, safe="")) - try: - _, _body = _http_request(url, target, method="DELETE") - except ( - urllib.error.HTTPError, - urllib.error.URLError, - OSError, - _ResponseUnparseable, - _ResponseTooLarge, - ) as e: - raise _handle_cloud_http_error(renderer, e, operation="delete", workflow_id=workflow_id) from e - - payload = {"workflow_id": workflow_id, "deleted": True} - if renderer.is_pretty(): - rprint(f"[green]✓[/green] deleted [dim]{workflow_id}[/dim]") - renderer.emit(payload, command="workflow delete", where="cloud", changed=True) + return _cloud_delete(renderer, target, workflow_id) # --------------------------------------------------------------------------- diff --git a/comfy_cli/error_codes.py b/comfy_cli/error_codes.py index 24b40a01a..c6ed96f95 100644 --- a/comfy_cli/error_codes.py +++ b/comfy_cli/error_codes.py @@ -141,9 +141,38 @@ class ErrorCode: "truncate it into a corrupt/partial file. `details.limit_bytes` carries the cap.", "the saved workflow is unexpectedly large; inspect it directly on the server", ), + ErrorCode( + "workflow_exists", + "`comfy workflow save --no-overwrite` found a saved workflow file with that name already (HTTP 409 " + "from the `/userdata` write), so nothing was written. `details.filename` is the file under " + "`workflows/`.", + "pass a different `--name`, or drop `--no-overwrite` to replace it", + ), + ErrorCode( + "workflow_record_unresolved", + "`comfy workflow save --where cloud` saved the file the Workflows sidebar lists, but could not read " + "back exactly one Cloud workflow record with that name and matching content (none yet, two sharing it, " + "stale mirrored content, or the `/api/workflows` read failed), so `workflow_id` is null. " + "Surfaced in `data.warnings[]`, not as an " + "error envelope: the save succeeded, so do not re-run it.", + "find the record with `comfy --json workflow list --name `", + ), + ErrorCode( + "workflow_filename_ambiguous", + "Cloud `workflow delete` found a sidebar file but could not safely associate it with the requested " + "record (duplicate names or an unresolved lookup). Nothing was deleted.", + "inspect same-name records; remove the intended file in the Cloud sidebar before deleting its record", + ), + ErrorCode( + "workflow_delete_incomplete", + "Cloud `workflow delete` removed the sidebar file, but could not confirm cleanup of its workflow " + "record. `details.file_deleted` is true; `details.workflow_id` identifies the record to check.", + "check `comfy --json workflow list`, then retry deleting the record if it remains", + ), ErrorCode( "workflow_unparseable", - "A cloud `/api/workflows` call returned a non-empty 200 body that couldn't be decoded as JSON " + "A cloud `/api/workflows` call, or the cloud `/userdata` write `workflow save` makes, returned a " + "non-empty 200 body that couldn't be decoded as JSON " "(non-UTF-8 bytes or a non-JSON body such as an HTML proxy/error page). Distinct from an empty " "body (legitimately no data): the malformed body is surfaced as a hard error rather than a " "misleading empty list / null id. `details.operation` carries the verb.", @@ -886,10 +915,10 @@ class ErrorCode: ), ErrorCode( "description_ignored", - "`comfy workflow save --where local --description` was given a description, but the local " - "file-backed `/userdata` store has nowhere to keep it. Surfaced in `data.warnings[]` " - "(not as an error envelope) so the save still succeeds.", - "descriptions are a Comfy Cloud feature; drop `--description` on the local path", + "`comfy workflow save --description` was given a description, but the saved workflow is a " + "`/userdata` file (on Cloud, the one the Workflows sidebar lists) with nowhere to keep it. " + "Surfaced in `data.warnings[]` (not as an error envelope) so the save still succeeds.", + "drop `--description`; put notes in the workflow itself, e.g. a Note node", ), ErrorCode( "cql_query_invalid", diff --git a/comfy_cli/skills/comfy/SKILL.md b/comfy_cli/skills/comfy/SKILL.md index cb40d28cd..d324436f3 100644 --- a/comfy_cli/skills/comfy/SKILL.md +++ b/comfy_cli/skills/comfy/SKILL.md @@ -683,10 +683,26 @@ JSON files on disk via `workflow slots/set-slot/vary` instead. comfy --json workflow list # paginated, sorted by create_time comfy --json workflow list --name "wan" --limit 5 # case-insensitive name filter comfy --json workflow get --out my.json # writes workflow JSON -comfy --json workflow save my.json --name "X" --description "Y" +comfy --json workflow save my.json --name "X" # → workflows/X.json in the sidebar +comfy --json workflow save my.json --name "X" --no-overwrite # refuse if X exists comfy --json workflow delete ``` +`workflow save` writes `workflows/.json`, the file the Cloud +**Workflows sidebar** lists, so tell the user it is there under that name +(an open tab needs a refresh) and opens from it. `data.filename` is that +entry; `data.workflow_id` is the record Cloud keeps for it. A +`workflow_record_unresolved` warning means only the id read-back failed — +the save landed, but the record may be missing or stale, so don't re-run it. +A same-name save replaces the +workflow; `--no-overwrite` refuses with `workflow_exists` instead. +`--description` is ignored (the file has no such field). +Cloud `workflow delete ` removes the sidebar file and record. If duplicate +names make the file association ambiguous, it leaves both unchanged with +`workflow_filename_ambiguous`; inspect the same-name records and remove the +intended file in the sidebar first. `workflow_delete_incomplete` means the file +was removed but record cleanup needs checking with `workflow list`. + ## Cancel a running job ```bash diff --git a/tests/comfy_cli/command/test_pretty_print_sanitize.py b/tests/comfy_cli/command/test_pretty_print_sanitize.py index ed8f70792..497f8c5c1 100644 --- a/tests/comfy_cli/command/test_pretty_print_sanitize.py +++ b/tests/comfy_cli/command/test_pretty_print_sanitize.py @@ -764,6 +764,34 @@ def test_local_workflow_list_table_is_inert(pretty): assert "boom" in assert_inert(pretty) +def test_cloud_workflow_save_receipt_names_the_sidebar_and_is_inert(pretty, tmp_path): + """`comfy workflow save --where cloud` prints the sidebar entry it wrote and + the record id Cloud returned, which is server-supplied; a warning is printed + too, since pretty mode drops `data.warnings`.""" + from comfy_cli.command import workflow + + src = tmp_path / "wf.json" + src.write_text(json.dumps({"nodes": [], "links": []})) + record = {"id": EVIL, "name": "flux", "latest_version": 1} + target = MagicMock() + target.url.side_effect = lambda *parts: "https://cloud.example/api/" + "/".join(parts) + + def _fake_http(url, _target, *, method="GET", body=None): + if method == "POST": + return (200, {"size": 2}) + if url.endswith("/content"): + return (200, {"workflow_json": {"nodes": [], "links": []}}) + return (200, {"data": [record]}) + + with patch.object(workflow, "_http_request", side_effect=_fake_http): + workflow._cloud_save(get_renderer(), target, str(src), "flux", "a note") + out = assert_inert(pretty) + assert "Cloud Workflows sidebar" in out + assert "workflows/flux.json" in out + assert "boom" in out + assert "--description is ignored" in out + + def test_cloud_workflow_list_table_is_inert(pretty): """The cloud saved-workflow catalog reaches the same sink.""" from comfy_cli.command import workflow diff --git a/tests/comfy_cli/command/test_workflow_saved.py b/tests/comfy_cli/command/test_workflow_saved.py index 4730b9d96..d1970b10c 100644 --- a/tests/comfy_cli/command/test_workflow_saved.py +++ b/tests/comfy_cli/command/test_workflow_saved.py @@ -1,7 +1,8 @@ """Tests for `comfy workflow list/get/save/delete` — saved workflows. The cloud path wraps the `/api/workflows` surface documented at -docs.comfy.org/api-reference/cloud/workflow. The local path (`--where local`) +docs.comfy.org/api-reference/cloud/workflow, except `save`, which writes the +`/api/userdata` file the Cloud Workflows sidebar lists. The local path (`--where local`) wraps the running ComfyUI's `/userdata` file store under `workflows/`, mirroring the ComfyUI frontend's layout. All HTTP is mocked; the live round-trip is verified manually. @@ -125,6 +126,8 @@ def _fake(req, timeout=None): calls.append({"url": url, "method": method, "body": body, "headers": dict(req.headers)}) for needle, payload in routes.items(): if needle in url: + if callable(payload): + payload = payload(req) if isinstance(payload, Exception): raise payload if isinstance(payload, tuple): @@ -412,6 +415,34 @@ def test_server_not_running_envelope(self, local_target, tmp_path, monkeypatch, assert env["ok"] is False assert env["error"]["code"] == "server_not_running" + def test_no_overwrite_sends_overwrite_false(self, local_target, tmp_path, monkeypatch, capsys): + wf = tmp_path / "src.json" + wf.write_text(json.dumps(_LOCAL_WORKFLOW)) + calls = _patch_urlopen(monkeypatch, {"/userdata/": {"path": "workflows/flux.json"}}) + env = _run(["save", str(wf), "--name", "flux", "--no-overwrite", "--where", "local"], capsys) + assert env["ok"] is True + assert "overwrite=false" in calls[0]["url"] + + def test_no_overwrite_collision_is_workflow_exists(self, local_target, tmp_path, monkeypatch, capsys): + # ComfyUI answers 409 when `overwrite=false` meets an existing file. + wf = tmp_path / "src.json" + wf.write_text(json.dumps(_LOCAL_WORKFLOW)) + _patch_urlopen(monkeypatch, {"/userdata/": _http_error(409)}) + env = _run(["save", str(wf), "--name", "flux", "--no-overwrite", "--where", "local"], capsys) + assert env["ok"] is False + assert env["where"] == "local" + assert env["error"]["code"] == "workflow_exists" + assert env["error"]["details"]["filename"] == "flux.json" + + def test_refuses_the_favorites_index(self, local_target, tmp_path, monkeypatch, capsys): + wf = tmp_path / "src.json" + wf.write_text(json.dumps(_LOCAL_WORKFLOW)) + calls = _patch_urlopen(monkeypatch, {}) + env = _run(["save", str(wf), "--name", ".index.json", "--where", "local"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "invalid_argument" + assert calls == [] + class TestLocalDelete: def test_sends_delete(self, local_target, monkeypatch, capsys): @@ -591,7 +622,8 @@ def test_every_call_site_routes_oversize_to_envelope(self, verb, cloud_target, t # Each of the four _http_request call sites must catch _ResponseTooLarge; # an uncaught one would surface as a traceback rather than an envelope. monkeypatch.setattr(workflow_cmd, "_HTTP_MAX_BYTES", 4) - _patch_urlopen(monkeypatch, {"/api/workflows": (b'{"data": []}', 200)}) + # `save` writes through `/api/userdata/`; the other three read `/api/workflows`. + _patch_urlopen(monkeypatch, {"/api/workflows": (b'{"data": []}', 200), "/api/userdata/": (b'{"a": 1}', 200)}) args = { "list": ["list"], "get": ["get", "wf-uuid"], @@ -622,29 +654,295 @@ def test_mutating_verbs_do_not_claim_the_write_was_rejected(self, verb): # --------------------------------------------------------------------------- +_MIRRORED_RECORD = { + "id": "33333333-3333-3333-3333-333333333333", + "name": "my workflow", + "default_view": "workflow", + "latest_version": 2, + "created_by": "user-uuid", + "created_at": "2026-05-23T00:00:00Z", + "updated_at": "2026-05-23T00:00:00Z", +} + +# Cloud's `POST /api/userdata/{file}?full_info=true` receipt: a FileInfo dict. +_USERDATA_SAVE_RESPONSE = {"path": "workflows/my workflow.json", "size": 64, "modified": 1700000003000} + + +def _record_listing(*rows: dict) -> dict: + return {"data": list(rows), "pagination": {"total": len(rows), "limit": 100, "offset": 0}} + + +def _cloud_wf(tmp_path: Path) -> tuple[Path, dict]: + wf_path = tmp_path / "wf.json" + wf_path.write_text(json.dumps(_LOCAL_WORKFLOW)) + return wf_path, _LOCAL_WORKFLOW + + +def _http_409(url: str = "https://cloud.example.com/api/userdata/x"): + return urllib.error.HTTPError(url, 409, "Conflict", {}, io.BytesIO(b"File already exists")) + + class TestSave: - def test_posts_workflow_payload(self, cloud_target, tmp_path, monkeypatch, capsys): - wf_path = tmp_path / "wf.json" - wf_data = {"1": {"class_type": "KSampler", "inputs": {"steps": 20}}} - wf_path.write_text(json.dumps(wf_data)) + """Cloud `workflow save` writes the file the Cloud Workflows sidebar lists. + + The sidebar lists `userdata/workflows/*.json`; a record created only through + `POST /api/workflows` has no file behind it and never shows there. So the save + is the frontend's own write, `POST /api/userdata/`, + which Cloud mirrors into its `/api/workflows` record store. The record id is + then read back by exact name. + """ + + def test_writes_the_sidebar_userdata_file(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path, wf_data = _cloud_wf(tmp_path) + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is True, env + assert env["where"] == "cloud" + + write = calls[0] + assert write["method"] == "POST" + # The whole `workflows/.json` path is one percent-encoded segment, + # exactly as the frontend's `encodeURIComponent(file)` sends it. + assert write["url"].startswith("https://cloud.example.com/api/userdata/workflows%2Fmy%20workflow.json?") + assert "overwrite=true" in write["url"] + assert "full_info=true" in write["url"] + # The body is the graph itself, not the `/api/workflows` {name, workflow_json} envelope. + assert json.loads(write["body"]) == wf_data + + # No bare `/api/workflows` record write: Cloud creates the record from the file. + assert not [c for c in calls if c["method"] == "POST" and "/api/workflows" in c["url"]] + + data = env["data"] + assert data["filename"] == "my workflow.json" + assert data["name"] == "my workflow" + assert data["workflow_id"] == _MIRRORED_RECORD["id"] + assert data["latest_version"] == 2 + assert data["size"] == 64 + assert data["source"] == str(wf_path) + assert "warnings" not in data + + def test_record_is_read_back_by_exact_name(self, cloud_target, tmp_path, monkeypatch, capsys): + # Cloud's `name` filter is a case-insensitive substring match, so the + # listing can carry near-misses. Only the exact name is the mirror. + wf_path, _ = _cloud_wf(tmp_path) + near_miss = {**_MIRRORED_RECORD, "id": "44444444-4444-4444-4444-444444444444", "name": "my workflow (copy)"} + cased = {**_MIRRORED_RECORD, "id": "55555555-5555-5555-5555-555555555555", "name": "My Workflow"} + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + "/api/workflows?": _record_listing(near_miss, cased, _MIRRORED_RECORD), + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["data"]["workflow_id"] == _MIRRORED_RECORD["id"] + lookup = calls[1] + assert lookup["method"] == "GET" + assert "name=my+workflow" in lookup["url"] + + def test_subdir_name_is_a_single_encoded_segment(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path, _ = _cloud_wf(tmp_path) + record = {**_MIRRORED_RECORD, "name": "team/flux"} + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": {"path": "team/flux.json"}, + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + "/api/workflows?": _record_listing(record), + }, + ) + env = _run(["save", str(wf_path), "--name", "team/flux", "--where", "cloud"], capsys) + assert env["ok"] is True + assert "/api/userdata/workflows%2Fteam%2Fflux.json?" in calls[0]["url"] + assert env["data"]["filename"] == "team/flux.json" + assert env["data"]["workflow_id"] == record["id"] + + def test_json_ext_is_not_doubled(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path, _ = _cloud_wf(tmp_path) + record = {**_MIRRORED_RECORD, "name": "flux"} + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": {}, + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + "/api/workflows?": _record_listing(record), + }, + ) + env = _run(["save", str(wf_path), "--name", "flux.json", "--where", "cloud"], capsys) + assert "workflows%2Fflux.json?" in calls[0]["url"] + # The record name Cloud derives drops the `.json`. + assert env["data"]["name"] == "flux" + assert env["data"]["workflow_id"] == record["id"] + + def test_uppercase_ext_still_gets_json_appended_on_cloud(self, cloud_target, tmp_path, monkeypatch, capsys): + # Cloud mirrors only names ending in a lowercase `.json` into a record, + # so `flux.JSON` is a stem, not an extension, on this route. + wf_path, _ = _cloud_wf(tmp_path) + calls = _patch_urlopen(monkeypatch, {"/api/userdata/": {}, "/api/workflows?": _record_listing()}) + env = _run(["save", str(wf_path), "--name", "flux.JSON", "--where", "cloud"], capsys) + assert "workflows%2Fflux.JSON.json?" in calls[0]["url"] + assert env["data"]["filename"] == "flux.JSON.json" + + def test_no_overwrite_sends_overwrite_false(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path, _ = _cloud_wf(tmp_path) + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--no-overwrite", "--where", "cloud"], capsys) + assert env["ok"] is True + assert "overwrite=false" in calls[0]["url"] - created = { - "id": "new-uuid", - "name": "my workflow", - "latest_version": 1, - "created_by": "user", - "created_at": "2026-05-23T00:00:00Z", - "updated_at": "2026-05-23T00:00:00Z", - } - calls = _patch_urlopen(monkeypatch, {"/api/workflows": created}) + def test_no_overwrite_collision_is_workflow_exists(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path, _ = _cloud_wf(tmp_path) + calls = _patch_urlopen(monkeypatch, {"/api/userdata/": _http_409()}) + env = _run(["save", str(wf_path), "--name", "my workflow", "--no-overwrite", "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["where"] == "cloud" + assert env["error"]["code"] == "workflow_exists" + assert env["error"]["details"]["filename"] == "my workflow.json" + assert "--no-overwrite" in env["error"]["hint"] + # Nothing was written, so there is no record to look up. + assert len(calls) == 1 + + def test_unauthorized_write_is_cloud_unauthorized(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path, _ = _cloud_wf(tmp_path) + denied = urllib.error.HTTPError( + "https://cloud.example.com/api/userdata/x", 401, "Unauthorized", {}, io.BytesIO(b"") + ) + _patch_urlopen(monkeypatch, {"/api/userdata/": denied}) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "cloud_unauthorized" + assert env["error"]["details"]["operation"] == "save" + + def test_unreachable_write_is_an_error(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path, _ = _cloud_wf(tmp_path) + _patch_urlopen(monkeypatch, {"/api/userdata/": urllib.error.URLError("refused")}) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "cloud_http_error" + + @pytest.mark.parametrize( + "listing", + [ + pytest.param(_record_listing(), id="no-record"), + pytest.param( + _record_listing(_MIRRORED_RECORD, {**_MIRRORED_RECORD, "id": "66666666-6666-6666-6666-666666666666"}), + id="two-records-one-name", + ), + pytest.param(urllib.error.URLError("reset"), id="lookup-unreachable"), + pytest.param((b"502", 200), id="lookup-unparseable"), + pytest.param( + # A full page may be truncated: the exact match it holds may not be the only one. + _record_listing( + _MIRRORED_RECORD, + *[{**_MIRRORED_RECORD, "id": f"id-{i}", "name": f"my workflow {i}"} for i in range(99)], + ), + id="full-page", + ), + ], + ) + def test_unresolved_record_keeps_the_save_and_warns(self, listing, cloud_target, tmp_path, monkeypatch, capsys): + # The file write has already landed when the record lookup runs, so a + # lookup that cannot name exactly one record must not fail the save (an + # agent would re-issue a save that already succeeded). It reports a null + # id and says why. + wf_path, _ = _cloud_wf(tmp_path) + _patch_urlopen(monkeypatch, {"/api/userdata/": _USERDATA_SAVE_RESPONSE, "/api/workflows?": listing}) env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) assert env["ok"] is True - assert env["data"]["workflow_id"] == "new-uuid" - # POSTed JSON carries the workflow_json + name. - assert calls[0]["method"] == "POST" - sent = json.loads(calls[0]["body"]) - assert sent["name"] == "my workflow" - assert sent["workflow_json"] == wf_data + assert env["data"]["filename"] == "my workflow.json" + assert env["data"]["workflow_id"] is None + assert env["data"]["latest_version"] is None + assert [w["code"] for w in env["data"]["warnings"]] == ["workflow_record_unresolved"] + + @pytest.mark.parametrize( + "content", + [ + {"workflow_json": {"nodes": [], "links": []}}, + urllib.error.URLError("mirror content unavailable"), + ], + ) + def test_stale_or_unreadable_mirror_does_not_return_record_id( + self, content, cloud_target, tmp_path, monkeypatch, capsys + ): + # The best-effort mirror may fail while an older same-name record remains. + wf_path, _ = _cloud_wf(tmp_path) + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/content": content, + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is True + assert env["data"]["workflow_id"] is None + assert env["data"]["warnings"][0]["code"] == "workflow_record_unresolved" + + @pytest.mark.parametrize("name", [".hidden", "team/.hidden/flow", ".json", "team/.json"]) + def test_hidden_names_are_refused_before_cloud_write(self, name, cloud_target, tmp_path, monkeypatch, capsys): + # Cloud's userdata listing excludes every dot-prefixed component. + wf_path, _ = _cloud_wf(tmp_path) + calls = _patch_urlopen(monkeypatch, {"/api/userdata/": {}, "/api/workflows?": _record_listing()}) + env = _run(["save", str(wf_path), "--name", name, "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "invalid_argument" + assert calls == [] + + def test_description_is_ignored_with_a_warning(self, cloud_target, tmp_path, monkeypatch, capsys): + # The sidebar file has no description field; say so rather than drop it silently. + wf_path, wf_data = _cloud_wf(tmp_path) + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + }, + ) + env = _run( + ["save", str(wf_path), "--name", "my workflow", "--description", "hi", "--where", "cloud"], + capsys, + ) + assert env["ok"] is True + assert [w["code"] for w in env["data"]["warnings"]] == ["description_ignored"] + assert json.loads(calls[0]["body"]) == wf_data + + @pytest.mark.parametrize("name", ["../escape", "/abs", "a\\b", ".index", "sub/.index.json"]) + def test_unsafe_or_reserved_names_are_refused_before_any_call( + self, name, cloud_target, tmp_path, monkeypatch, capsys + ): + # `.index.json` is the frontend's favorites file in the same folder; a + # save under that name would replace the user's bookmarks. + wf_path, _ = _cloud_wf(tmp_path) + calls = _patch_urlopen(monkeypatch, {}) + env = _run(["save", str(wf_path), "--name", name, "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "invalid_argument" + assert calls == [] + + def test_non_utf8_file_surfaces_read_error(self, cloud_target, tmp_path, monkeypatch, capsys): + wf = tmp_path / "bin.json" + wf.write_bytes(b"\xff\xfe\x00") + _patch_urlopen(monkeypatch, {}) + env = _run(["save", str(wf), "--name", "x", "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "workflow_read_error" def test_invalid_json_file_surfaces_workflow_invalid_json(self, cloud_target, tmp_path, monkeypatch, capsys): wf_path = tmp_path / "bad.json" @@ -667,13 +965,200 @@ def test_missing_file_surfaces_workflow_not_found(self, cloud_target, tmp_path, # --------------------------------------------------------------------------- +def test_cloud_save_list_get_delete_round_trip(cloud_target, tmp_path, monkeypatch, capsys): + # Mirror the verified Cloud handler boundaries: file POST mirrors a record, + # file DELETE mirrors record removal, record DELETE alone removes only a record. + state = {"file": None, "record": False} + + def file(req): + if req.get_method() == "POST": + state["file"] = json.loads(req.data) + state["record"] = True + return _USERDATA_SAVE_RESPONSE + if req.get_method() == "DELETE": + state["file"] = None + state["record"] = False + return (b"", 204) + return state["file"] + + def record(req): + if not state["record"]: + return urllib.error.HTTPError(req.full_url, 404, "Not found", {}, io.BytesIO()) + if req.full_url.endswith("/content"): + return {"id": "v2", "version": 2, "workflow_json": state["file"]} + if req.get_method() == "DELETE": + state["record"] = False + return (b"", 204) + return _MIRRORED_RECORD + + def listing(req): + return _record_listing(_MIRRORED_RECORD) if state["record"] else _record_listing() + + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": file, + "/api/workflows?": listing, + "/api/workflows/": record, + "/api/user": {"id": "user-uuid"}, + }, + ) + src, workflow_json = _cloud_wf(tmp_path) + saved = _run(["save", str(src), "--name", "my workflow", "--where", "cloud"], capsys) + workflow_id = saved["data"]["workflow_id"] + listed = _run(["list", "--where", "cloud"], capsys) + assert listed["data"]["workflows"][0]["id"] == workflow_id + out = tmp_path / "downloaded.json" + fetched = _run(["get", workflow_id, "--out", str(out), "--where", "cloud"], capsys) + assert fetched["ok"] is True + assert json.loads(out.read_text()) == workflow_json + deleted = _run(["delete", workflow_id, "--where", "cloud"], capsys) + assert deleted["ok"] is True + assert state == {"file": None, "record": False} + listed = _run(["list", "--where", "cloud"], capsys) + assert listed["data"]["count"] == 0 + + +class TestCloudDeleteFile: + @pytest.mark.parametrize( + ("content", "creator", "user"), + [ + pytest.param({"nodes": []}, "user-uuid", {"id": "user-uuid"}, id="unrelated-file"), + pytest.param(_LOCAL_WORKFLOW, "other-user", {"id": "user-uuid"}, id="other-members-record"), + pytest.param(_LOCAL_WORKFLOW, None, {"id": "user-uuid"}, id="unknown-record-owner"), + pytest.param(_LOCAL_WORKFLOW, "user-uuid", {}, id="unknown-current-user"), + ], + ) + def test_unverified_file_association_leaves_file_and_record_untouched( + self, content, creator, user, cloud_target, monkeypatch, capsys + ): + # A same-name record can be stale after a best-effort sync failure, or + # belong to a different workspace member. Neither authorizes file deletion. + record = {**_MIRRORED_RECORD, "created_by": creator} + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _LOCAL_WORKFLOW, + "/content": {"workflow_json": content}, + "/api/workflows?": _record_listing(record), + "/api/workflows/": record, + "/api/user": user, + }, + ) + env = _run(["delete", record["id"], "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "workflow_filename_ambiguous" + assert all(call["method"] == "GET" for call in calls) + + @pytest.mark.parametrize("dual_delete", [True, False]) + def test_delete_removes_sidebar_file_and_record(self, dual_delete, cloud_target, monkeypatch, capsys): + # Cloud's userdata delete mirrors best-effort; record DELETE alone leaves the file behind. + state = {"file": True, "record": True} + + def record(req): + if req.full_url.endswith("/content"): + return {"workflow_json": _LOCAL_WORKFLOW} + if req.get_method() == "GET": + return _MIRRORED_RECORD + if not state["record"]: + return urllib.error.HTTPError(req.full_url, 404, "Not found", {}, io.BytesIO()) + state["record"] = False + return (b"", 204) + + def file(req): + if req.get_method() == "DELETE": + state["file"] = False + if dual_delete: + state["record"] = False + return (b"", 204) + return _LOCAL_WORKFLOW + + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": file, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/api/workflows/": record, + "/api/user": {"id": "user-uuid"}, + }, + ) + env = _run(["delete", _MIRRORED_RECORD["id"], "--where", "cloud"], capsys) + assert env["ok"] is True, env + assert state == {"file": False, "record": False} + assert env["data"]["filename"] == "my workflow.json" + + def test_duplicate_names_leave_file_and_records_untouched(self, cloud_target, monkeypatch, capsys): + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _LOCAL_WORKFLOW, + "/api/workflows?": _record_listing(_MIRRORED_RECORD, {**_MIRRORED_RECORD, "id": "other-id"}), + "/api/workflows/": _MIRRORED_RECORD, + }, + ) + env = _run(["delete", _MIRRORED_RECORD["id"], "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "workflow_filename_ambiguous" + assert all(c["method"] == "GET" for c in calls) + + @pytest.mark.parametrize("name", [" leading space", ".index", "../outside"]) + def test_unsafe_record_name_cannot_delete_another_file(self, name, cloud_target, monkeypatch, capsys): + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _LOCAL_WORKFLOW, + "/api/workflows?": _record_listing({**_MIRRORED_RECORD, "name": name}), + "/api/workflows/": {**_MIRRORED_RECORD, "name": name}, + }, + ) + env = _run(["delete", _MIRRORED_RECORD["id"], "--where", "cloud"], capsys) + assert env["ok"] is False + assert all(c["method"] == "GET" for c in calls) + + def test_partial_failure_reports_file_already_deleted(self, cloud_target, monkeypatch, capsys): + def record(req): + if req.full_url.endswith("/content"): + return {"workflow_json": _LOCAL_WORKFLOW} + if req.get_method() == "GET": + return _MIRRORED_RECORD + return urllib.error.HTTPError(req.full_url, 503, "Unavailable", {}, io.BytesIO()) + + def file(req): + return (b"", 204) if req.get_method() == "DELETE" else _LOCAL_WORKFLOW + + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": file, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/api/workflows/": record, + "/api/user": {"id": "user-uuid"}, + }, + ) + env = _run(["delete", _MIRRORED_RECORD["id"], "--where", "cloud"], capsys) + assert env["ok"] is False + assert env["error"]["code"] == "workflow_delete_incomplete" + assert env["error"]["details"]["file_deleted"] is True + assert env["error"]["details"]["workflow_id"] == _MIRRORED_RECORD["id"] + + def test_record_only_workflow_still_deletes(self, cloud_target, monkeypatch, capsys): + def record(req): + return _MIRRORED_RECORD if req.get_method() == "GET" else (b"", 204) + + missing = urllib.error.HTTPError("https://x/userdata/x", 404, "Not Found", {}, io.BytesIO()) + calls = _patch_urlopen(monkeypatch, {"/api/userdata/": missing, "/api/workflows/": record}) + env = _run(["delete", _MIRRORED_RECORD["id"], "--where", "cloud"], capsys) + assert env["ok"] is True + assert [c["method"] for c in calls] == ["GET", "GET", "DELETE"] + + class TestDelete: def test_sends_delete_request(self, cloud_target, monkeypatch, capsys): - calls = _patch_urlopen(monkeypatch, {"/api/workflows/wf-uuid": (b"", 204)}) + calls = _patch_urlopen(monkeypatch, {"/api/workflows/wf-uuid": {"id": "wf-uuid"}}) env = _run(["delete", "wf-uuid", "--where", "cloud"], capsys) assert env["ok"] is True assert env["data"]["deleted"] is True - assert calls[0]["method"] == "DELETE" + assert [c["method"] for c in calls] == ["GET", "DELETE"] def test_404_surfaces_workflow_not_found(self, cloud_target, monkeypatch, capsys): err = urllib.error.HTTPError("https://x/workflows/g", 404, "Not Found", {}, io.BytesIO(b"{}")) @@ -720,9 +1205,12 @@ def test_list_surfaces_error_not_empty(self, cloud_target, monkeypatch, capsys, def test_save_surfaces_error_not_null_id(self, cloud_target, tmp_path, monkeypatch, capsys, raw): wf_path = tmp_path / "wf.json" wf_path.write_text(json.dumps({"1": {"class_type": "KSampler", "inputs": {}}})) - _patch_urlopen(monkeypatch, {"/api/workflows": (raw, 200)}) + calls = _patch_urlopen(monkeypatch, {"/api/userdata/": (raw, 200)}) env = _run(["save", str(wf_path), "--name", "x", "--where", "cloud"], capsys) - # Must NOT claim success with a null workflow_id. + # The save's write is the userdata POST; its receipt is what came back malformed. + assert "/api/userdata/workflows%2Fx.json" in calls[0]["url"] + # Must NOT claim success off a body it could not read (an HTML 200 can be a + # proxy page that never reached Cloud). assert env["ok"] is False assert env["error"]["code"] == "workflow_unparseable" assert env["error"]["details"]["operation"] == "save" From fe4acd5f69d14be6bb87967f4d02213370d39b07 Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Tue, 27 Oct 2026 17:46:05 -0700 Subject: [PATCH 2/9] fix(workflow): preserve JSON types when verifying mirrored records --- comfy_cli/command/workflow.py | 17 +++- .../comfy_cli/command/test_workflow_saved.py | 86 +++++++++++++++++++ 2 files changed, 102 insertions(+), 1 deletion(-) diff --git a/comfy_cli/command/workflow.py b/comfy_cli/command/workflow.py index a5a003c06..1b5031bbe 100644 --- a/comfy_cli/command/workflow.py +++ b/comfy_cli/command/workflow.py @@ -47,6 +47,21 @@ # --------------------------------------------------------------------------- +def _same_json(left: Any, right: Any) -> bool: + """Compare JSON values without equating booleans with numbers. + + JSON has one number type, so integer and floating-point representations of + the same number still match. Objects are unordered; arrays are ordered. + """ + if type(left) is not type(right): + return type(left) in (int, float) and type(right) in (int, float) and left == right + if isinstance(left, dict): + return left.keys() == right.keys() and all(_same_json(left[key], right[key]) for key in left) + if isinstance(left, list): + return len(left) == len(right) and all(_same_json(a, b) for a, b in zip(left, right)) + return left == right + + def _is_frontend_format(data: Any) -> bool: """Heuristic: frontend format has ``nodes`` as a list. API format has it as a dict keyed by IDs.""" return isinstance(data, dict) and isinstance(data.get("nodes"), list) @@ -1477,7 +1492,7 @@ def _find_mirrored_record(target, record_name: str, workflow_json: dict | None = ) except (urllib.error.URLError, OSError, _ResponseUnparseable, _ResponseTooLarge): return None - if not isinstance(content, dict) or content.get("workflow_json") != workflow_json: + if not isinstance(content, dict) or not _same_json(content.get("workflow_json"), workflow_json): return None return record diff --git a/tests/comfy_cli/command/test_workflow_saved.py b/tests/comfy_cli/command/test_workflow_saved.py index b5c7dd43f..73c436920 100644 --- a/tests/comfy_cli/command/test_workflow_saved.py +++ b/tests/comfy_cli/command/test_workflow_saved.py @@ -764,6 +764,15 @@ def test_mutating_verbs_do_not_claim_the_write_was_rejected(self, verb): # Cloud's `POST /api/userdata/{file}?full_info=true` receipt: a FileInfo dict. _USERDATA_SAVE_RESPONSE = {"path": "workflows/my workflow.json", "size": 64, "modified": 1700000003000} +_BOOL_NUMBER_MISMATCHES = [ + pytest.param(1, True, id="one-vs-true"), + pytest.param(0, False, id="zero-vs-false"), + pytest.param(True, 1, id="true-vs-one"), + pytest.param(False, 0, id="false-vs-zero"), + pytest.param({"nested": [1]}, {"nested": [True]}, id="nested-one-vs-true"), + pytest.param({"nested": [False]}, {"nested": [0]}, id="nested-false-vs-zero"), +] + def _record_listing(*rows: dict) -> dict: return {"data": list(rows), "pagination": {"total": len(rows), "limit": 100, "offset": 0}} @@ -991,6 +1000,44 @@ def test_stale_or_unreadable_mirror_does_not_return_record_id( assert env["data"]["workflow_id"] is None assert env["data"]["warnings"][0]["code"] == "workflow_record_unresolved" + @pytest.mark.parametrize(("file_value", "record_value"), _BOOL_NUMBER_MISMATCHES) + def test_bool_number_mirror_mismatch_withholds_record_id( + self, file_value, record_value, cloud_target, tmp_path, monkeypatch, capsys + ): + wf_path = tmp_path / "wf.json" + wf_path.write_text(json.dumps({"nodes": [{"id": 1, "widgets_values": [file_value]}]})) + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/content": {"workflow_json": {"nodes": [{"id": 1, "widgets_values": [record_value]}]}}, + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is True + assert env["data"]["workflow_id"] is None + assert env["data"]["latest_version"] is None + assert env["data"]["warnings"][0]["code"] == "workflow_record_unresolved" + + def test_equivalent_json_numbers_resolve_mirrored_record(self, cloud_target, tmp_path, monkeypatch, capsys): + wf_path = tmp_path / "wf.json" + wf_path.write_text('{"nodes": [{"id": 1, "widgets_values": [{"nested": [1, true, null]}]}]}') + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/content": { + "workflow_json": {"nodes": [{"widgets_values": [{"nested": [1.0, True, None]}], "id": 1.0}]} + }, + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is True + assert env["data"]["workflow_id"] == _MIRRORED_RECORD["id"] + assert "warnings" not in env["data"] + @pytest.mark.parametrize("name", [".hidden", "team/.hidden/flow", ".json", "team/.json"]) def test_hidden_names_are_refused_before_cloud_write(self, name, cloud_target, tmp_path, monkeypatch, capsys): # Cloud's userdata listing excludes every dot-prefixed component. @@ -1117,6 +1164,45 @@ def listing(req): class TestCloudDeleteFile: + @pytest.mark.parametrize(("file_value", "record_value"), _BOOL_NUMBER_MISMATCHES) + def test_bool_number_mirror_mismatch_refuses_both_deletes( + self, file_value, record_value, cloud_target, monkeypatch, capsys + ): + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": {"nodes": [{"id": 1, "widgets_values": [file_value]}]}, + "/content": {"workflow_json": {"nodes": [{"id": 1, "widgets_values": [record_value]}]}}, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/api/workflows/": _MIRRORED_RECORD, + "/api/user": {"id": "user-uuid"}, + }, + ) + env = _run(["delete", _MIRRORED_RECORD["id"], "--where", "cloud"], capsys) + assert not [call for call in calls if call["method"] == "DELETE"] + assert env["ok"] is False + assert env["error"]["code"] == "workflow_filename_ambiguous" + + def test_equivalent_json_numbers_allow_both_deletes(self, cloud_target, monkeypatch, capsys): + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": {"nodes": [{"id": 1, "widgets_values": [{"nested": [1, True, None]}]}]}, + "/content": { + "workflow_json": {"nodes": [{"widgets_values": [{"nested": [1.0, True, None]}], "id": 1.0}]} + }, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/api/workflows/": _MIRRORED_RECORD, + "/api/user": {"id": "user-uuid"}, + }, + ) + env = _run(["delete", _MIRRORED_RECORD["id"], "--where", "cloud"], capsys) + assert env["ok"] is True + assert [call["url"] for call in calls if call["method"] == "DELETE"] == [ + "https://cloud.example.com/api/userdata/workflows%2Fmy%20workflow.json", + "https://cloud.example.com/api/workflows/33333333-3333-3333-3333-333333333333", + ] + @pytest.mark.parametrize( ("content", "creator", "user"), [ From 45b878ef468a34eed21eb38e57f7e99445beafd2 Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Tue, 27 Oct 2026 19:39:43 -0700 Subject: [PATCH 3/9] test(cli): isolate preflight catalogs and platform trust fixtures --- tests/comfy_cli/command/test_run.py | 21 +++-- tests/comfy_cli/command/test_run_json.py | 92 ++++++++++++------- tests/comfy_cli/command/test_run_prompt.py | 16 +++- .../output/test_error_envelope_where.py | 8 +- tests/comfy_cli/test_http.py | 5 +- 5 files changed, 91 insertions(+), 51 deletions(-) diff --git a/tests/comfy_cli/command/test_run.py b/tests/comfy_cli/command/test_run.py index 9731c0233..e5c93051d 100644 --- a/tests/comfy_cli/command/test_run.py +++ b/tests/comfy_cli/command/test_run.py @@ -2363,14 +2363,16 @@ def test_markup_in_node_name_does_not_crash_confirm(self, monkeypatch): class TestExecuteUiWorkflow: + # The conversion success fixture must also be an executable graph: + # PreviewImage consumes IMAGE, not an EmptyLatentImage's LATENT output. UI = { "nodes": [ { "id": 1, - "type": "EmptyLatentImage", + "type": "EmptyImage", "inputs": [], - "outputs": [{"name": "LATENT", "type": "LATENT", "links": [10]}], - "widgets_values": [512, 512, 1], + "outputs": [{"name": "IMAGE", "type": "IMAGE", "links": [10]}], + "widgets_values": [512, 512, 1, 0], "mode": 0, }, { @@ -2384,19 +2386,20 @@ class TestExecuteUiWorkflow: "links": [[10, 1, 0, 2, 0, "IMAGE"]], } OBJECT_INFO = { - "EmptyLatentImage": { + "EmptyImage": { "input": { "required": { "width": ["INT", {"default": 512}], "height": ["INT", {"default": 512}], "batch_size": ["INT", {"default": 1}], + "color": ["INT", {"default": 0}], } }, - "input_order": {"required": ["width", "height", "batch_size"]}, - "output": ["LATENT"], - "output_name": ["LATENT"], + "input_order": {"required": ["width", "height", "batch_size", "color"]}, + "output": ["IMAGE"], + "output_name": ["IMAGE"], "output_node": False, - "display_name": "Empty Latent Image", + "display_name": "Empty Image", }, "PreviewImage": { "input": {"required": {"images": ["IMAGE"]}}, @@ -2435,7 +2438,7 @@ def test_ui_workflow_is_converted_then_executed(self, ui_workflow_file): assert mock_fetch.call_args.args == ("127.0.0.1", 8188, 30) api_workflow = MockExec.call_args.args[0] assert set(api_workflow) == {"1", "2"} - assert api_workflow["1"]["class_type"] == "EmptyLatentImage" + assert api_workflow["1"]["class_type"] == "EmptyImage" assert api_workflow["2"]["inputs"]["images"] == ["1", 0] mock_exec.queue.assert_called_once() diff --git a/tests/comfy_cli/command/test_run_json.py b/tests/comfy_cli/command/test_run_json.py index f0dcfde1f..84d7b3496 100644 --- a/tests/comfy_cli/command/test_run_json.py +++ b/tests/comfy_cli/command/test_run_json.py @@ -52,13 +52,30 @@ def ndjson_renderer(): reset_renderer_for_testing() +@pytest.fixture(autouse=True) +def local_preflight_catalog(monkeypatch): + """Keep event/queue tests independent of any real server on localhost. + + Validation still runs against complete schemas. Tests for conversion HTTP + and deliberately invalid catalogs override their specific boundary below. + """ + from copy import deepcopy + + monkeypatch.setattr("comfy_cli.command.run._fetch_object_info", lambda *a, **k: deepcopy(OBJECT_INFO)) + + def unexpected_catalog_request(*args, **kwargs): + pytest.fail("unexpected real catalog request; mock the specific object_info transport") + + monkeypatch.setattr("comfy_cli.http._PLAIN_OPENER.open", unexpected_catalog_request) + + @pytest.fixture def simple_workflow(): return { "1": { - "class_type": "EmptyLatentImage", - "inputs": {"width": 64, "height": 64, "batch_size": 1}, - "_meta": {"title": "Latent"}, + "class_type": "EmptyImage", + "inputs": {"width": 64, "height": 64, "batch_size": 1, "color": 0}, + "_meta": {"title": "Image"}, }, "2": { "class_type": "SaveImage", @@ -524,8 +541,8 @@ def test_queued_nodes_manifest_from_workflow(self, workflow_file, capsys, simple nodes = queued["nodes"] assert len(nodes) == 2 by_id = {n["node_id"]: n for n in nodes} - assert by_id["1"]["class_type"] == "EmptyLatentImage" - assert by_id["1"]["title"] == "Latent" # _meta.title wins + assert by_id["1"]["class_type"] == "EmptyImage" + assert by_id["1"]["title"] == "Image" # _meta.title wins assert by_id["2"]["class_type"] == "SaveImage" assert by_id["2"]["title"] == "Save" @@ -621,7 +638,7 @@ def test_execution_error(self, workflow_file, capsys): "data": { "prompt_id": "p", "node_id": "1", - "node_type": "EmptyLatentImage", + "node_type": "EmptyImage", "exception_type": "RuntimeError", "exception_message": "boom", "traceback": [' File "x.py"\n', " raise RuntimeError\n"], @@ -635,12 +652,12 @@ def test_execution_error(self, workflow_file, capsys): assert any(e["type"] == "execution_error" for e in _events(lines)) env = _envelope(lines) assert env["error"]["code"] == "execution_error" - assert env["error"]["message"] == "EmptyLatentImage (node 1): boom" + assert env["error"]["message"] == "EmptyImage (node 1): boom" details = env["error"]["details"] assert details["node_id"] == "1" - assert details["class_type"] == "EmptyLatentImage" + assert details["class_type"] == "EmptyImage" assert details["exception_type"] == "RuntimeError" - assert details["title"] == "Latent" # from _meta.title + assert details["title"] == "Image" # from _meta.title # The envelope carries only the traceback tail; the full traceback # stays on the execution_error event. assert isinstance(details["traceback_tail"], list) @@ -658,7 +675,7 @@ def test_execution_error_node_id_coerced_to_str(self, workflow_file, capsys): "data": { "prompt_id": "p", "node_id": 7, - "node_type": "EmptyLatentImage", + "node_type": "EmptyImage", "exception_type": "RuntimeError", "exception_message": "boom", "traceback": [], @@ -797,8 +814,8 @@ def test_node_ids_coerced_to_str(self, simple_workflow, capsys): assert isinstance(ev["node"], str), f"{ev['type']} node is {type(ev['node']).__name__}" def test_title_falls_back_to_class_type(self): - ex = _make_workflow_execution({"1": {"class_type": "EmptyLatentImage", "inputs": {}}}) - assert ex.get_node_title("1") == "EmptyLatentImage" + ex = _make_workflow_execution({"1": {"class_type": "EmptyImage", "inputs": {}}}) + assert ex.get_node_title("1") == "EmptyImage" def test_title_falls_back_to_node_id_for_unknown(self): ex = _make_workflow_execution({}) @@ -809,10 +826,10 @@ def test_title_falls_back_to_node_id_for_unknown(self): "nodes": [ { "id": 1, - "type": "EmptyLatentImage", + "type": "EmptyImage", "inputs": [], - "outputs": [{"name": "LATENT", "type": "LATENT", "links": [10]}], - "widgets_values": [64, 64, 1], + "outputs": [{"name": "IMAGE", "type": "IMAGE", "links": [10]}], + "widgets_values": [64, 64, 1, 0], "mode": 0, }, { @@ -827,17 +844,26 @@ def test_title_falls_back_to_node_id_for_unknown(self): } OBJECT_INFO = { - "EmptyLatentImage": { + "EmptyImage": { "input": { "required": { "width": ["INT", {"default": 512}], "height": ["INT", {"default": 512}], "batch_size": ["INT", {"default": 1}], + "color": ["INT", {"default": 0}], } }, - "input_order": {"required": ["width", "height", "batch_size"]}, + "input_order": {"required": ["width", "height", "batch_size", "color"]}, + "output": ["IMAGE"], + "output_name": ["IMAGE"], "output_node": False, - "display_name": "Empty Latent Image", + "display_name": "Empty Image", + }, + "SaveImage": { + "input": {"required": {"filename_prefix": ["STRING", {"default": "ComfyUI"}], "images": ["IMAGE"]}}, + "input_order": {"required": ["filename_prefix", "images"]}, + "output": [], + "output_node": True, }, "PreviewImage": { "input": {"required": {"images": ["IMAGE"]}}, @@ -970,7 +996,7 @@ def test_api_input_emits_prompt_preview_before_queued(self, workflow_file, capsy assert types[0] == "prompt_preview" assert "queued" in types assert types.index("prompt_preview") < types.index("queued") - assert _events(lines)[0]["prompt"]["1"]["class_type"] == "EmptyLatentImage" + assert _events(lines)[0]["prompt"]["1"]["class_type"] == "EmptyImage" def test_ui_input_emits_converted_then_prompt_preview_then_queued(self, ui_workflow_file, capsys): with ( @@ -1035,7 +1061,7 @@ def test_api_input_emits_prompt_preview_and_envelope_only(self, workflow_file, c assert [e["type"] for e in _events(lines)] == ["prompt_preview"] preview = _events(lines)[0] assert preview["schema"] == "event/1" - assert preview["prompt"]["1"]["class_type"] == "EmptyLatentImage" + assert preview["prompt"]["1"]["class_type"] == "EmptyImage" env = _envelope(lines) assert env["ok"] is True assert env["data"]["status"] == "preview" @@ -1092,7 +1118,7 @@ def test_print_prompt_text_mode_pretty_prints_json(self, workflow_file, capsys): out, _err = capsys.readouterr() parsed = json.loads(out) assert "1" in parsed - assert parsed["1"]["class_type"] == "EmptyLatentImage" + assert parsed["1"]["class_type"] == "EmptyImage" def test_print_prompt_does_not_post_when_workflow_invalid(self, capsys): # Pre-flight failures (workflow_not_found, workflow_not_api_format) @@ -1240,10 +1266,10 @@ def test_execution_cached_event_shape(self, workflow_file, capsys): cached_events = [e for e in _events(lines) if e["type"] == "execution_cached"] assert len(cached_events) == 2 - # Node 1 has _meta.title="Latent"; class_type=EmptyLatentImage + # Node 1 has _meta.title="Image"; class_type=EmptyImage n1 = next(e for e in cached_events if e["node"] == "1") - assert n1["class_type"] == "EmptyLatentImage" - assert n1["title"] == "Latent" + assert n1["class_type"] == "EmptyImage" + assert n1["title"] == "Image" # Node 2 has _meta.title="Save"; class_type=SaveImage n2 = next(e for e in cached_events if e["node"] == "2") assert n2["class_type"] == "SaveImage" @@ -1380,9 +1406,9 @@ class TestErrorPathCoverage: def _make_workflow(self): return { "1": { - "class_type": "EmptyLatentImage", - "inputs": {"width": 64, "height": 64, "batch_size": 1}, - "_meta": {"title": "Latent"}, + "class_type": "EmptyImage", + "inputs": {"width": 64, "height": 64, "batch_size": 1, "color": 0}, + "_meta": {"title": "Image"}, }, "2": { "class_type": "SaveImage", @@ -1399,10 +1425,10 @@ def test_object_info_timeout_routes_to_connection_error(self, capsys): "nodes": [ { "id": 1, - "type": "EmptyLatentImage", + "type": "EmptyImage", "inputs": [], "outputs": [], - "widgets_values": [64, 64, 1], + "widgets_values": [64, 64, 1, 0], "mode": 0, } ], @@ -1414,7 +1440,7 @@ def test_object_info_timeout_routes_to_connection_error(self, capsys): try: with ( patch("comfy_cli.command.run.check_comfy_server_running", return_value=True), - patch("comfy_cli.http._AUTHED_OPENER.open", side_effect=TimeoutError("timed out")), + patch("comfy_cli.http._PLAIN_OPENER.open", side_effect=TimeoutError("timed out")), ): lines, exit_code = _run_execute_capture(path, capsys) assert _envelope(lines)["error"]["code"] == "connection_error" @@ -1427,10 +1453,10 @@ def test_object_info_non_json_body_routes_to_object_info_unavailable(self, capsy "nodes": [ { "id": 1, - "type": "EmptyLatentImage", + "type": "EmptyImage", "inputs": [], "outputs": [], - "widgets_values": [64, 64, 1], + "widgets_values": [64, 64, 1, 0], "mode": 0, } ], @@ -1876,7 +1902,7 @@ def test_api_workflow_async_stream_matches_documented_archetype( assert isinstance(queued["client_id"], str) and queued["client_id"] assert queued["validation_warnings"] == [] assert queued["nodes"] == [ - {"node_id": "1", "class_type": "EmptyLatentImage", "title": "Latent"}, + {"node_id": "1", "class_type": "EmptyImage", "title": "Image"}, {"node_id": "2", "class_type": "SaveImage", "title": "Save"}, ] assert queued["base_url"] == "https://api.comfy.org" diff --git a/tests/comfy_cli/command/test_run_prompt.py b/tests/comfy_cli/command/test_run_prompt.py index c67139558..da6f3c557 100644 --- a/tests/comfy_cli/command/test_run_prompt.py +++ b/tests/comfy_cli/command/test_run_prompt.py @@ -9,6 +9,8 @@ from __future__ import annotations +import json +from pathlib import Path from unittest.mock import MagicMock, patch import pytest @@ -32,11 +34,15 @@ class TestExecuteSubmitsPreloadedGraph: """`preloaded` short-circuits file loading; the in-memory graph is what reaches the submit path (WorkflowExecution).""" + @pytest.fixture(autouse=True) + def preloaded_catalog(self): + """Validate the injected graph against a frozen catalog, without a server.""" + catalog = json.loads((Path(__file__).resolve().parents[1] / "fixtures/sd15_object_info.json").read_text()) + with patch("comfy_cli.command.run._fetch_object_info", return_value=catalog): + yield + def test_preloaded_graph_is_submitted(self): - injected = { - "6": {"class_type": "CLIPTextEncode", "inputs": {"text": "a red fox in snow"}}, - "9": {"class_type": "SaveImage", "inputs": {"images": ["8", 0]}}, - } + injected = build_default_workflow(prompt="a red fox in snow") with ( patch("comfy_cli.command.run.check_comfy_server_running", return_value=True), patch("comfy_cli.command.run.ExecutionProgress"), @@ -63,7 +69,7 @@ def test_preloaded_graph_is_submitted(self): def test_preloaded_skips_file_loading(self): """A non-existent path never triggers workflow_not_found when preloaded.""" - injected = {"9": {"class_type": "SaveImage", "inputs": {}}} + injected = build_default_workflow(prompt="fox") with ( patch("comfy_cli.command.run.check_comfy_server_running", return_value=True), patch("comfy_cli.command.run.ExecutionProgress"), diff --git a/tests/comfy_cli/output/test_error_envelope_where.py b/tests/comfy_cli/output/test_error_envelope_where.py index e84ae3a06..ed0ae837f 100644 --- a/tests/comfy_cli/output/test_error_envelope_where.py +++ b/tests/comfy_cli/output/test_error_envelope_where.py @@ -324,15 +324,19 @@ def _workflow(tmp_path): def test_cloud(self, tmp_path): err = LoadError("no object_info", details={"hint": "sign in"}) - with patch("comfy_cli.cql.engine.Graph.load", side_effect=err): + with patch("comfy_cli.cql.loader.resilient_load_object_info", side_effect=err) as load: env = _run(["--json", "validate", "--workflow", self._workflow(tmp_path), "--where", "cloud"]) + load.assert_called_once() + assert load.call_args.kwargs["mode"] == "cloud" assert env["error"]["code"] == "cql_no_graph" assert env["where"] == "cloud" def test_local(self, tmp_path): err = LoadError("no object_info", details={"hint": "comfy launch"}) - with patch("comfy_cli.cql.engine.Graph.load", side_effect=err): + with patch("comfy_cli.cql.loader.resilient_load_object_info", side_effect=err) as load: env = _run(["--json", "validate", "--workflow", self._workflow(tmp_path), "--where", "local"]) + load.assert_called_once() + assert load.call_args.kwargs["mode"] == "local" assert env["error"]["code"] == "cql_no_graph" assert env["where"] == "local" diff --git a/tests/comfy_cli/test_http.py b/tests/comfy_cli/test_http.py index 703199d85..20adb7027 100644 --- a/tests/comfy_cli/test_http.py +++ b/tests/comfy_cli/test_http.py @@ -819,7 +819,6 @@ def test_an_unloadable_supplement_falls_through_to_the_platform_roots(tmp_path, monkeypatch.setitem(sys.modules, "certifi", types.SimpleNamespace(where=lambda: str(broken))) real = ssl.create_default_context - populated = len(pathlib.Path(certifi.where()).read_text().split("-----BEGIN CERTIFICATE-----")) - 1 def platform_with_roots(*args, **kwargs): context = real(*args, **kwargs) @@ -827,13 +826,15 @@ def platform_with_roots(*args, **kwargs): context.load_verify_locations(cafile=certifi.where()) return context + expected_roots = set(platform_with_roots().get_ca_certs(binary_form=True)) + assert expected_roots, "the platform fixture must contain trust roots" monkeypatch.setattr(ssl, "create_default_context", platform_with_roots) # When context = http_mod.ssl_context() # Then - assert context.cert_store_stats()["x509_ca"] == populated, ( + assert set(context.get_ca_certs(binary_form=True)) == expected_roots, ( "the platform roots must survive a supplement that would not load" ) From e0c90be2262cbf49dd7ba525ff471074e9901370 Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Fri, 30 Oct 2026 10:07:07 -0700 Subject: [PATCH 4/9] Expose userdata saved-file UUID separately from workflow records --- comfy_cli/command/workflow.py | 28 +++++++- comfy_cli/schemas/workflow.json | 5 ++ docs/workflow-save.md | 18 +++++ .../comfy_cli/command/test_workflow_saved.py | 71 ++++++++++++++++++- 4 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 docs/workflow-save.md diff --git a/comfy_cli/command/workflow.py b/comfy_cli/command/workflow.py index 1b5031bbe..75e0d6221 100644 --- a/comfy_cli/command/workflow.py +++ b/comfy_cli/command/workflow.py @@ -1497,6 +1497,21 @@ def _find_mirrored_record(target, record_name: str, workflow_json: dict | None = return record +def _saved_file_id(info: object, key: str) -> str | None: + """Use only the actual userdata write receipt, never a mirrored record ID.""" + from uuid import UUID + + if not isinstance(info, dict) or info.get("path") != f"{_WORKFLOWS_DIR}/{key}": + return None + identity = info.get("id") + if not isinstance(identity, str): + return None + try: + return identity if str(UUID(identity)) == identity else None + except ValueError: + return None + + def _cloud_save( renderer, target, workflow_file: str, name: str, description: str | None, *, overwrite: bool = True ) -> None: @@ -1516,11 +1531,13 @@ def _cloud_save( except (urllib.error.URLError, OSError, _ResponseUnparseable, _ResponseTooLarge) as e: raise _handle_cloud_http_error(renderer, e, operation="save") from e + saved_file_id = _saved_file_id(info, key) record_name = _cloud_record_name(key) record = _find_mirrored_record(target, record_name, workflow_json) if record_name else None latest = record.get("latest_version") if record else None payload: dict[str, Any] = { "workflow_id": record["id"] if record else None, + "saved_file_id": saved_file_id, "name": record_name or key, "filename": key, "latest_version": latest if isinstance(latest, int) and not isinstance(latest, bool) else None, @@ -1536,6 +1553,15 @@ def _cloud_save( "message": "--description is ignored: the Cloud Workflows sidebar file has no description field", } ) + if saved_file_id is None: + warnings.append( + { + "code": "saved_file_identity_unavailable", + "message": "The file was saved, but this server did not return its canonical saved_file_id; " + "a private saved-file link cannot be certified. Verify the file in the Cloud Workflows sidebar; " + "do not repeat the save or uploads to obtain an ID. workflow_id identifies a separate record.", + } + ) if record is None: warnings.append( { @@ -1911,7 +1937,7 @@ def get_cmd( help=( "Save a workflow JSON as workflows/.json. On Comfy Cloud it appears in the Workflows sidebar " "(refresh an open tab) and opens from there; Cloud also keeps a workflow record for it, returned as " - "workflow_id. With --where local it lands in the local ComfyUI's /userdata workflows/ folder. " + "workflow_id and, when the server returns it, the separate userdata saved_file_id. With --where local it lands in the local ComfyUI's /userdata workflows/ folder. " "A save under an existing name replaces it unless --no-overwrite." ), ) diff --git a/comfy_cli/schemas/workflow.json b/comfy_cli/schemas/workflow.json index 2869ab1f3..5b52ecf01 100644 --- a/comfy_cli/schemas/workflow.json +++ b/comfy_cli/schemas/workflow.json @@ -5,6 +5,11 @@ "type": "object", "properties": { "workflow": { "type": "string" }, + "saved_file_id": { + "type": ["string", "null"], + "format": "uuid", + "description": "Cloud save: actual userdata UUID from the write receipt, distinct from the mirrored workflow_id record. Null when the server cannot certify file identity; do not repeat the save." + }, "count": { "type": "integer" }, "total": { "type": "integer", diff --git a/docs/workflow-save.md b/docs/workflow-save.md new file mode 100644 index 000000000..efe8a5009 --- /dev/null +++ b/docs/workflow-save.md @@ -0,0 +1,18 @@ +# Saving a workflow to the Cloud sidebar + +`comfy --json workflow save workflow.json --name "My workflow" --where cloud` +writes the normal `workflows/My workflow.json` userdata file once. It returns +`filename` and, when supported by the server, `saved_file_id`: the actual userdata +UUID from that write receipt. The UUID survives ordinary saves and renames; a +deleted and recreated file has a new identity. + +`workflow_id` remains the separate mirrored workflow-record ID used by the +record-based list/get/delete commands. A same-name record with equal content does +not establish the saved file's UUID. Never substitute `workflow_id` for +`saved_file_id` or construct a private editor URL from either value alone. + +Older servers can save successfully without returning a usable file UUID. In +that case `saved_file_id` is null and `saved_file_identity_unavailable` explains +that private file-link certification is unavailable. Verify the saved file in +Cloud's Workflows sidebar; do not repeat the save or any local file uploads to +obtain an ID. File identity metadata does not grant upload permission. diff --git a/tests/comfy_cli/command/test_workflow_saved.py b/tests/comfy_cli/command/test_workflow_saved.py index 73c436920..9e5243c1e 100644 --- a/tests/comfy_cli/command/test_workflow_saved.py +++ b/tests/comfy_cli/command/test_workflow_saved.py @@ -762,7 +762,13 @@ def test_mutating_verbs_do_not_claim_the_write_was_rejected(self, verb): } # Cloud's `POST /api/userdata/{file}?full_info=true` receipt: a FileInfo dict. -_USERDATA_SAVE_RESPONSE = {"path": "workflows/my workflow.json", "size": 64, "modified": 1700000003000} +_SAVED_FILE_ID = "978e5f58-49dc-4a81-8235-a0b91c204a1c" +_USERDATA_SAVE_RESPONSE = { + "id": _SAVED_FILE_ID, + "path": "workflows/my workflow.json", + "size": 64, + "modified": 1700000003000, +} _BOOL_NUMBER_MISMATCHES = [ pytest.param(1, True, id="one-vs-true"), @@ -1451,3 +1457,66 @@ def test_list_missing_data_is_empty(self, cloud_target, monkeypatch, capsys): env = _run(["list", "--where", "cloud"], capsys) assert env["ok"] is True assert env["data"]["count"] == 0 + + +@pytest.mark.parametrize( + "identity", [None, "", 12, True, "not-a-uuid", "a" * 32, "978E5F58-49DC-4A81-8235-A0B91C204A1C"] +) +def test_cloud_save_without_canonical_file_id_keeps_success_and_record_separate( + cloud_target, tmp_path, monkeypatch, capsys, identity +): + wf_path, _ = _cloud_wf(tmp_path) + receipt = {**_USERDATA_SAVE_RESPONSE, "id": identity} + if identity is None: + receipt.pop("id") + calls = _patch_urlopen( + monkeypatch, + { + "/api/userdata/": receipt, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is True + assert env["data"]["saved_file_id"] is None + assert env["data"]["workflow_id"] == _MIRRORED_RECORD["id"] + warning = next(w for w in env["data"]["warnings"] if w["code"] == "saved_file_identity_unavailable") + assert "do not repeat" in warning["message"] + assert len([c for c in calls if c["method"] == "POST"]) == 1 + + +def test_cloud_save_exposes_received_file_uuid_distinct_from_equal_content_record( + cloud_target, tmp_path, monkeypatch, capsys +): + wf_path, _ = _cloud_wf(tmp_path) + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": _USERDATA_SAVE_RESPONSE, + "/api/workflows?": _record_listing(_MIRRORED_RECORD), + "/content": {"workflow_json": _LOCAL_WORKFLOW}, + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is True + assert env["data"]["saved_file_id"] == _SAVED_FILE_ID + assert env["data"]["workflow_id"] == _MIRRORED_RECORD["id"] + assert env["data"]["saved_file_id"] != env["data"]["workflow_id"] + + +@pytest.mark.parametrize("path", [None, "workflows/other.json", "my workflow.json"]) +def test_cloud_save_other_receipt_path_does_not_certify_requested_file( + cloud_target, tmp_path, monkeypatch, capsys, path +): + wf_path, _ = _cloud_wf(tmp_path) + _patch_urlopen( + monkeypatch, + { + "/api/userdata/": {**_USERDATA_SAVE_RESPONSE, "path": path}, + "/api/workflows?": _record_listing(), + }, + ) + env = _run(["save", str(wf_path), "--name", "my workflow", "--where", "cloud"], capsys) + assert env["ok"] is True + assert env["data"]["saved_file_id"] is None From e0cfd9b8f3bee651c837c6a2d107df10d1e979f7 Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Fri, 30 Oct 2026 10:14:35 -0700 Subject: [PATCH 5/9] Match saved-file UUID receipts to the frontend consumer contract --- comfy_cli/command/workflow.py | 10 +- comfy_cli/saved_file_identity.py | 17 + .../comfy_cli/command/test_workflow_saved.py | 13 +- .../fixtures/saved_file_uuid_consumer.json | 1355 +++++++++++++++++ tests/comfy_cli/test_saved_file_identity.py | 51 + 5 files changed, 1437 insertions(+), 9 deletions(-) create mode 100644 comfy_cli/saved_file_identity.py create mode 100644 tests/comfy_cli/fixtures/saved_file_uuid_consumer.json create mode 100644 tests/comfy_cli/test_saved_file_identity.py diff --git a/comfy_cli/command/workflow.py b/comfy_cli/command/workflow.py index 75e0d6221..857a0d8b6 100644 --- a/comfy_cli/command/workflow.py +++ b/comfy_cli/command/workflow.py @@ -1499,17 +1499,11 @@ def _find_mirrored_record(target, record_name: str, workflow_json: dict | None = def _saved_file_id(info: object, key: str) -> str | None: """Use only the actual userdata write receipt, never a mirrored record ID.""" - from uuid import UUID + from comfy_cli.saved_file_identity import canonical_saved_file_id if not isinstance(info, dict) or info.get("path") != f"{_WORKFLOWS_DIR}/{key}": return None - identity = info.get("id") - if not isinstance(identity, str): - return None - try: - return identity if str(UUID(identity)) == identity else None - except ValueError: - return None + return canonical_saved_file_id(info.get("id")) def _cloud_save( diff --git a/comfy_cli/saved_file_identity.py b/comfy_cli/saved_file_identity.py new file mode 100644 index 000000000..46d7621c0 --- /dev/null +++ b/comfy_cli/saved_file_identity.py @@ -0,0 +1,17 @@ +"""Saved userdata UUID contract shared by save receipts and link publication.""" + +from __future__ import annotations + +import re + +# Browser consumer: uuid11.1.1 validate(), plus lowercase canonical wire form. +# Accept RFC9562 versions1..8 and variants8..b, plus its explicit NIL/MAX cases. +_SAVED_FILE_UUID = re.compile( + r"(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}" + r"|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)" +) + + +def canonical_saved_file_id(value: object) -> str | None: + """Return a received canonical ID, without deriving or coercing one.""" + return value if isinstance(value, str) and _SAVED_FILE_UUID.fullmatch(value) else None diff --git a/tests/comfy_cli/command/test_workflow_saved.py b/tests/comfy_cli/command/test_workflow_saved.py index 9e5243c1e..0df3228b7 100644 --- a/tests/comfy_cli/command/test_workflow_saved.py +++ b/tests/comfy_cli/command/test_workflow_saved.py @@ -1460,7 +1460,18 @@ def test_list_missing_data_is_empty(self, cloud_target, monkeypatch, capsys): @pytest.mark.parametrize( - "identity", [None, "", 12, True, "not-a-uuid", "a" * 32, "978E5F58-49DC-4A81-8235-A0B91C204A1C"] + "identity", + [ + None, + "", + 12, + True, + "not-a-uuid", + "a" * 32, + "978E5F58-49DC-4A81-8235-A0B91C204A1C", + "11111111-1111-1111-1111-111111111111", + "11111111-1111-9111-8111-111111111111", + ], ) def test_cloud_save_without_canonical_file_id_keeps_success_and_record_separate( cloud_target, tmp_path, monkeypatch, capsys, identity diff --git a/tests/comfy_cli/fixtures/saved_file_uuid_consumer.json b/tests/comfy_cli/fixtures/saved_file_uuid_consumer.json new file mode 100644 index 000000000..f41bd1388 --- /dev/null +++ b/tests/comfy_cli/fixtures/saved_file_uuid_consumer.json @@ -0,0 +1,1355 @@ +{ + "provenance": { + "package": "uuid", + "version": "11.1.1", + "consumer": "savedWorkflowService.ts and savedWorkflowLink.ts: uuid.validate(id) && id === id.toLowerCase()", + "regex_sha256": "774bc4bc767a58458dfdd252430d96b71b3d380ac241b50df6cb757aaa1b4783" + }, + "cases": [ + { + "id": "version-0-variant-0", + "input": "11111111-1111-0111-0111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-1", + "input": "11111111-1111-0111-1111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-2", + "input": "11111111-1111-0111-2111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-3", + "input": "11111111-1111-0111-3111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-4", + "input": "11111111-1111-0111-4111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-5", + "input": "11111111-1111-0111-5111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-6", + "input": "11111111-1111-0111-6111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-7", + "input": "11111111-1111-0111-7111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-8", + "input": "11111111-1111-0111-8111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-9", + "input": "11111111-1111-0111-9111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-a", + "input": "11111111-1111-0111-a111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-b", + "input": "11111111-1111-0111-b111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-c", + "input": "11111111-1111-0111-c111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-d", + "input": "11111111-1111-0111-d111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-e", + "input": "11111111-1111-0111-e111-111111111111", + "accepted": false + }, + { + "id": "version-0-variant-f", + "input": "11111111-1111-0111-f111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-0", + "input": "11111111-1111-1111-0111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-1", + "input": "11111111-1111-1111-1111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-2", + "input": "11111111-1111-1111-2111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-3", + "input": "11111111-1111-1111-3111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-4", + "input": "11111111-1111-1111-4111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-5", + "input": "11111111-1111-1111-5111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-6", + "input": "11111111-1111-1111-6111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-7", + "input": "11111111-1111-1111-7111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-8", + "input": "11111111-1111-1111-8111-111111111111", + "accepted": true + }, + { + "id": "version-1-variant-9", + "input": "11111111-1111-1111-9111-111111111111", + "accepted": true + }, + { + "id": "version-1-variant-a", + "input": "11111111-1111-1111-a111-111111111111", + "accepted": true + }, + { + "id": "version-1-variant-b", + "input": "11111111-1111-1111-b111-111111111111", + "accepted": true + }, + { + "id": "version-1-variant-c", + "input": "11111111-1111-1111-c111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-d", + "input": "11111111-1111-1111-d111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-e", + "input": "11111111-1111-1111-e111-111111111111", + "accepted": false + }, + { + "id": "version-1-variant-f", + "input": "11111111-1111-1111-f111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-0", + "input": "11111111-1111-2111-0111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-1", + "input": "11111111-1111-2111-1111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-2", + "input": "11111111-1111-2111-2111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-3", + "input": "11111111-1111-2111-3111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-4", + "input": "11111111-1111-2111-4111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-5", + "input": "11111111-1111-2111-5111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-6", + "input": "11111111-1111-2111-6111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-7", + "input": "11111111-1111-2111-7111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-8", + "input": "11111111-1111-2111-8111-111111111111", + "accepted": true + }, + { + "id": "version-2-variant-9", + "input": "11111111-1111-2111-9111-111111111111", + "accepted": true + }, + { + "id": "version-2-variant-a", + "input": "11111111-1111-2111-a111-111111111111", + "accepted": true + }, + { + "id": "version-2-variant-b", + "input": "11111111-1111-2111-b111-111111111111", + "accepted": true + }, + { + "id": "version-2-variant-c", + "input": "11111111-1111-2111-c111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-d", + "input": "11111111-1111-2111-d111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-e", + "input": "11111111-1111-2111-e111-111111111111", + "accepted": false + }, + { + "id": "version-2-variant-f", + "input": "11111111-1111-2111-f111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-0", + "input": "11111111-1111-3111-0111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-1", + "input": "11111111-1111-3111-1111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-2", + "input": "11111111-1111-3111-2111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-3", + "input": "11111111-1111-3111-3111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-4", + "input": "11111111-1111-3111-4111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-5", + "input": "11111111-1111-3111-5111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-6", + "input": "11111111-1111-3111-6111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-7", + "input": "11111111-1111-3111-7111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-8", + "input": "11111111-1111-3111-8111-111111111111", + "accepted": true + }, + { + "id": "version-3-variant-9", + "input": "11111111-1111-3111-9111-111111111111", + "accepted": true + }, + { + "id": "version-3-variant-a", + "input": "11111111-1111-3111-a111-111111111111", + "accepted": true + }, + { + "id": "version-3-variant-b", + "input": "11111111-1111-3111-b111-111111111111", + "accepted": true + }, + { + "id": "version-3-variant-c", + "input": "11111111-1111-3111-c111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-d", + "input": "11111111-1111-3111-d111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-e", + "input": "11111111-1111-3111-e111-111111111111", + "accepted": false + }, + { + "id": "version-3-variant-f", + "input": "11111111-1111-3111-f111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-0", + "input": "11111111-1111-4111-0111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-1", + "input": "11111111-1111-4111-1111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-2", + "input": "11111111-1111-4111-2111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-3", + "input": "11111111-1111-4111-3111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-4", + "input": "11111111-1111-4111-4111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-5", + "input": "11111111-1111-4111-5111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-6", + "input": "11111111-1111-4111-6111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-7", + "input": "11111111-1111-4111-7111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-8", + "input": "11111111-1111-4111-8111-111111111111", + "accepted": true + }, + { + "id": "version-4-variant-9", + "input": "11111111-1111-4111-9111-111111111111", + "accepted": true + }, + { + "id": "version-4-variant-a", + "input": "11111111-1111-4111-a111-111111111111", + "accepted": true + }, + { + "id": "version-4-variant-b", + "input": "11111111-1111-4111-b111-111111111111", + "accepted": true + }, + { + "id": "version-4-variant-c", + "input": "11111111-1111-4111-c111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-d", + "input": "11111111-1111-4111-d111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-e", + "input": "11111111-1111-4111-e111-111111111111", + "accepted": false + }, + { + "id": "version-4-variant-f", + "input": "11111111-1111-4111-f111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-0", + "input": "11111111-1111-5111-0111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-1", + "input": "11111111-1111-5111-1111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-2", + "input": "11111111-1111-5111-2111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-3", + "input": "11111111-1111-5111-3111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-4", + "input": "11111111-1111-5111-4111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-5", + "input": "11111111-1111-5111-5111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-6", + "input": "11111111-1111-5111-6111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-7", + "input": "11111111-1111-5111-7111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-8", + "input": "11111111-1111-5111-8111-111111111111", + "accepted": true + }, + { + "id": "version-5-variant-9", + "input": "11111111-1111-5111-9111-111111111111", + "accepted": true + }, + { + "id": "version-5-variant-a", + "input": "11111111-1111-5111-a111-111111111111", + "accepted": true + }, + { + "id": "version-5-variant-b", + "input": "11111111-1111-5111-b111-111111111111", + "accepted": true + }, + { + "id": "version-5-variant-c", + "input": "11111111-1111-5111-c111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-d", + "input": "11111111-1111-5111-d111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-e", + "input": "11111111-1111-5111-e111-111111111111", + "accepted": false + }, + { + "id": "version-5-variant-f", + "input": "11111111-1111-5111-f111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-0", + "input": "11111111-1111-6111-0111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-1", + "input": "11111111-1111-6111-1111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-2", + "input": "11111111-1111-6111-2111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-3", + "input": "11111111-1111-6111-3111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-4", + "input": "11111111-1111-6111-4111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-5", + "input": "11111111-1111-6111-5111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-6", + "input": "11111111-1111-6111-6111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-7", + "input": "11111111-1111-6111-7111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-8", + "input": "11111111-1111-6111-8111-111111111111", + "accepted": true + }, + { + "id": "version-6-variant-9", + "input": "11111111-1111-6111-9111-111111111111", + "accepted": true + }, + { + "id": "version-6-variant-a", + "input": "11111111-1111-6111-a111-111111111111", + "accepted": true + }, + { + "id": "version-6-variant-b", + "input": "11111111-1111-6111-b111-111111111111", + "accepted": true + }, + { + "id": "version-6-variant-c", + "input": "11111111-1111-6111-c111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-d", + "input": "11111111-1111-6111-d111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-e", + "input": "11111111-1111-6111-e111-111111111111", + "accepted": false + }, + { + "id": "version-6-variant-f", + "input": "11111111-1111-6111-f111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-0", + "input": "11111111-1111-7111-0111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-1", + "input": "11111111-1111-7111-1111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-2", + "input": "11111111-1111-7111-2111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-3", + "input": "11111111-1111-7111-3111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-4", + "input": "11111111-1111-7111-4111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-5", + "input": "11111111-1111-7111-5111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-6", + "input": "11111111-1111-7111-6111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-7", + "input": "11111111-1111-7111-7111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-8", + "input": "11111111-1111-7111-8111-111111111111", + "accepted": true + }, + { + "id": "version-7-variant-9", + "input": "11111111-1111-7111-9111-111111111111", + "accepted": true + }, + { + "id": "version-7-variant-a", + "input": "11111111-1111-7111-a111-111111111111", + "accepted": true + }, + { + "id": "version-7-variant-b", + "input": "11111111-1111-7111-b111-111111111111", + "accepted": true + }, + { + "id": "version-7-variant-c", + "input": "11111111-1111-7111-c111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-d", + "input": "11111111-1111-7111-d111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-e", + "input": "11111111-1111-7111-e111-111111111111", + "accepted": false + }, + { + "id": "version-7-variant-f", + "input": "11111111-1111-7111-f111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-0", + "input": "11111111-1111-8111-0111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-1", + "input": "11111111-1111-8111-1111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-2", + "input": "11111111-1111-8111-2111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-3", + "input": "11111111-1111-8111-3111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-4", + "input": "11111111-1111-8111-4111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-5", + "input": "11111111-1111-8111-5111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-6", + "input": "11111111-1111-8111-6111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-7", + "input": "11111111-1111-8111-7111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-8", + "input": "11111111-1111-8111-8111-111111111111", + "accepted": true + }, + { + "id": "version-8-variant-9", + "input": "11111111-1111-8111-9111-111111111111", + "accepted": true + }, + { + "id": "version-8-variant-a", + "input": "11111111-1111-8111-a111-111111111111", + "accepted": true + }, + { + "id": "version-8-variant-b", + "input": "11111111-1111-8111-b111-111111111111", + "accepted": true + }, + { + "id": "version-8-variant-c", + "input": "11111111-1111-8111-c111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-d", + "input": "11111111-1111-8111-d111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-e", + "input": "11111111-1111-8111-e111-111111111111", + "accepted": false + }, + { + "id": "version-8-variant-f", + "input": "11111111-1111-8111-f111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-0", + "input": "11111111-1111-9111-0111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-1", + "input": "11111111-1111-9111-1111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-2", + "input": "11111111-1111-9111-2111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-3", + "input": "11111111-1111-9111-3111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-4", + "input": "11111111-1111-9111-4111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-5", + "input": "11111111-1111-9111-5111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-6", + "input": "11111111-1111-9111-6111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-7", + "input": "11111111-1111-9111-7111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-8", + "input": "11111111-1111-9111-8111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-9", + "input": "11111111-1111-9111-9111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-a", + "input": "11111111-1111-9111-a111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-b", + "input": "11111111-1111-9111-b111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-c", + "input": "11111111-1111-9111-c111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-d", + "input": "11111111-1111-9111-d111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-e", + "input": "11111111-1111-9111-e111-111111111111", + "accepted": false + }, + { + "id": "version-9-variant-f", + "input": "11111111-1111-9111-f111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-0", + "input": "11111111-1111-a111-0111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-1", + "input": "11111111-1111-a111-1111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-2", + "input": "11111111-1111-a111-2111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-3", + "input": "11111111-1111-a111-3111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-4", + "input": "11111111-1111-a111-4111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-5", + "input": "11111111-1111-a111-5111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-6", + "input": "11111111-1111-a111-6111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-7", + "input": "11111111-1111-a111-7111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-8", + "input": "11111111-1111-a111-8111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-9", + "input": "11111111-1111-a111-9111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-a", + "input": "11111111-1111-a111-a111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-b", + "input": "11111111-1111-a111-b111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-c", + "input": "11111111-1111-a111-c111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-d", + "input": "11111111-1111-a111-d111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-e", + "input": "11111111-1111-a111-e111-111111111111", + "accepted": false + }, + { + "id": "version-a-variant-f", + "input": "11111111-1111-a111-f111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-0", + "input": "11111111-1111-b111-0111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-1", + "input": "11111111-1111-b111-1111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-2", + "input": "11111111-1111-b111-2111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-3", + "input": "11111111-1111-b111-3111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-4", + "input": "11111111-1111-b111-4111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-5", + "input": "11111111-1111-b111-5111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-6", + "input": "11111111-1111-b111-6111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-7", + "input": "11111111-1111-b111-7111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-8", + "input": "11111111-1111-b111-8111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-9", + "input": "11111111-1111-b111-9111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-a", + "input": "11111111-1111-b111-a111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-b", + "input": "11111111-1111-b111-b111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-c", + "input": "11111111-1111-b111-c111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-d", + "input": "11111111-1111-b111-d111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-e", + "input": "11111111-1111-b111-e111-111111111111", + "accepted": false + }, + { + "id": "version-b-variant-f", + "input": "11111111-1111-b111-f111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-0", + "input": "11111111-1111-c111-0111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-1", + "input": "11111111-1111-c111-1111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-2", + "input": "11111111-1111-c111-2111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-3", + "input": "11111111-1111-c111-3111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-4", + "input": "11111111-1111-c111-4111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-5", + "input": "11111111-1111-c111-5111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-6", + "input": "11111111-1111-c111-6111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-7", + "input": "11111111-1111-c111-7111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-8", + "input": "11111111-1111-c111-8111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-9", + "input": "11111111-1111-c111-9111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-a", + "input": "11111111-1111-c111-a111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-b", + "input": "11111111-1111-c111-b111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-c", + "input": "11111111-1111-c111-c111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-d", + "input": "11111111-1111-c111-d111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-e", + "input": "11111111-1111-c111-e111-111111111111", + "accepted": false + }, + { + "id": "version-c-variant-f", + "input": "11111111-1111-c111-f111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-0", + "input": "11111111-1111-d111-0111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-1", + "input": "11111111-1111-d111-1111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-2", + "input": "11111111-1111-d111-2111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-3", + "input": "11111111-1111-d111-3111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-4", + "input": "11111111-1111-d111-4111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-5", + "input": "11111111-1111-d111-5111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-6", + "input": "11111111-1111-d111-6111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-7", + "input": "11111111-1111-d111-7111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-8", + "input": "11111111-1111-d111-8111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-9", + "input": "11111111-1111-d111-9111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-a", + "input": "11111111-1111-d111-a111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-b", + "input": "11111111-1111-d111-b111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-c", + "input": "11111111-1111-d111-c111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-d", + "input": "11111111-1111-d111-d111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-e", + "input": "11111111-1111-d111-e111-111111111111", + "accepted": false + }, + { + "id": "version-d-variant-f", + "input": "11111111-1111-d111-f111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-0", + "input": "11111111-1111-e111-0111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-1", + "input": "11111111-1111-e111-1111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-2", + "input": "11111111-1111-e111-2111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-3", + "input": "11111111-1111-e111-3111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-4", + "input": "11111111-1111-e111-4111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-5", + "input": "11111111-1111-e111-5111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-6", + "input": "11111111-1111-e111-6111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-7", + "input": "11111111-1111-e111-7111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-8", + "input": "11111111-1111-e111-8111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-9", + "input": "11111111-1111-e111-9111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-a", + "input": "11111111-1111-e111-a111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-b", + "input": "11111111-1111-e111-b111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-c", + "input": "11111111-1111-e111-c111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-d", + "input": "11111111-1111-e111-d111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-e", + "input": "11111111-1111-e111-e111-111111111111", + "accepted": false + }, + { + "id": "version-e-variant-f", + "input": "11111111-1111-e111-f111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-0", + "input": "11111111-1111-f111-0111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-1", + "input": "11111111-1111-f111-1111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-2", + "input": "11111111-1111-f111-2111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-3", + "input": "11111111-1111-f111-3111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-4", + "input": "11111111-1111-f111-4111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-5", + "input": "11111111-1111-f111-5111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-6", + "input": "11111111-1111-f111-6111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-7", + "input": "11111111-1111-f111-7111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-8", + "input": "11111111-1111-f111-8111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-9", + "input": "11111111-1111-f111-9111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-a", + "input": "11111111-1111-f111-a111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-b", + "input": "11111111-1111-f111-b111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-c", + "input": "11111111-1111-f111-c111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-d", + "input": "11111111-1111-f111-d111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-e", + "input": "11111111-1111-f111-e111-111111111111", + "accepted": false + }, + { + "id": "version-f-variant-f", + "input": "11111111-1111-f111-f111-111111111111", + "accepted": false + }, + { + "id": "boundary-256", + "input": "00000000-0000-0000-0000-000000000000", + "accepted": true + }, + { + "id": "boundary-257", + "input": "ffffffff-ffff-ffff-ffff-ffffffffffff", + "accepted": true + }, + { + "id": "boundary-258", + "input": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", + "accepted": false + }, + { + "id": "boundary-259", + "input": "978E5F58-49DC-4A81-8235-A0B91C204A1C", + "accepted": false + }, + { + "id": "boundary-260", + "input": "978e5f58-49dc-4a81-8235-a0b91c204a1c", + "accepted": true + }, + { + "id": "boundary-261", + "input": "978e5f5849dc4a818235a0b91c204a1c", + "accepted": false + }, + { + "id": "boundary-262", + "input": " 978e5f58-49dc-4a81-8235-a0b91c204a1c", + "accepted": false + }, + { + "id": "boundary-263", + "input": "978e5f58-49dc-4a81-8235-a0b91c204a1c\n", + "accepted": false + }, + { + "id": "boundary-264", + "input": "", + "accepted": false + }, + { + "id": "boundary-265", + "input": null, + "accepted": false + }, + { + "id": "boundary-266", + "input": true, + "accepted": false + }, + { + "id": "boundary-267", + "input": 123, + "accepted": false + }, + { + "id": "boundary-268", + "input": {}, + "accepted": false + } + ] +} diff --git a/tests/comfy_cli/test_saved_file_identity.py b/tests/comfy_cli/test_saved_file_identity.py new file mode 100644 index 000000000..a40bccc65 --- /dev/null +++ b/tests/comfy_cli/test_saved_file_identity.py @@ -0,0 +1,51 @@ +"""Parity with the frontend's pinned uuid11.1.1 validator and lowercase wire ID.""" + +import json +from pathlib import Path + +import pytest + +from comfy_cli.saved_file_identity import canonical_saved_file_id + + +@pytest.mark.parametrize("version", range(1, 9)) +@pytest.mark.parametrize("variant", "89ab") +def test_rfc_versions_and_variants(version, variant): + identity = f"11111111-1111-{version}111-{variant}111-111111111111" + assert canonical_saved_file_id(identity) == identity + + +@pytest.mark.parametrize("identity", ["00000000-0000-0000-0000-000000000000", "ffffffff-ffff-ffff-ffff-ffffffffffff"]) +def test_frontend_nil_and_max_special_cases(identity): + assert canonical_saved_file_id(identity) == identity + + +@pytest.mark.parametrize( + "identity", + [ + None, + True, + 123, + "", + "a" * 32, + "11111111-1111-0111-8111-111111111111", + "11111111-1111-9111-8111-111111111111", + "11111111-1111-f111-8111-111111111111", + "11111111-1111-4111-7111-111111111111", + "11111111-1111-4111-c111-111111111111", + "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF", + "978E5F58-49DC-4A81-8235-A0B91C204A1C", + " 978e5f58-49dc-4a81-8235-a0b91c204a1c", + "978e5f58-49dc-4a81-8235-a0b91c204a1c\n", + ], +) +def test_malformed_or_noncanonical_received_ids_are_not_advertised(identity): + assert canonical_saved_file_id(identity) is None + + +_CONSUMER = json.loads((Path(__file__).parent / "fixtures/saved_file_uuid_consumer.json").read_text()) + + +@pytest.mark.parametrize("case", _CONSUMER["cases"], ids=lambda case: case["id"]) +def test_matches_actual_pinned_frontend_uuid_consumer(case): + assert (canonical_saved_file_id(case["input"]) is not None) is case["accepted"] From c142b635c2caa91aa5acc4b7f98e8c3aa5f5fa92 Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Fri, 30 Oct 2026 10:15:48 -0700 Subject: [PATCH 6/9] Register saved-file identity warning as a navigation signal --- comfy_cli/error_codes.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/comfy_cli/error_codes.py b/comfy_cli/error_codes.py index da12bcd19..61e35d1f4 100644 --- a/comfy_cli/error_codes.py +++ b/comfy_cli/error_codes.py @@ -148,6 +148,14 @@ class ErrorCode: "`workflows/`.", "pass a different `--name`, or drop `--no-overwrite` to replace it", ), + ErrorCode( + "saved_file_identity_unavailable", + "`comfy workflow save --where cloud` saved the sidebar file, but its write receipt did not return " + "a usable canonical userdata UUID for that exact path. `saved_file_id` is null. Surfaced in " + "`data.warnings[]`: the save succeeded; a same-name or equal-content workflow record does not " + "certify file identity.", + "verify the file in Cloud's Workflows sidebar; do not repeat the save or uploads solely to obtain an ID", + ), ErrorCode( "workflow_record_unresolved", "`comfy workflow save --where cloud` saved the file the Workflows sidebar lists, but could not read " From 09a5f38b683a1cec90aed2733aeda4502676fd2f Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Sat, 31 Oct 2026 12:02:51 -0700 Subject: [PATCH 7/9] test(run): isolate UI workflow preflight catalog --- tests/comfy_cli/command/test_run.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/comfy_cli/command/test_run.py b/tests/comfy_cli/command/test_run.py index e5c93051d..3af335823 100644 --- a/tests/comfy_cli/command/test_run.py +++ b/tests/comfy_cli/command/test_run.py @@ -2363,6 +2363,19 @@ def test_markup_in_node_name_does_not_crash_confirm(self, monkeypatch): class TestExecuteUiWorkflow: + @pytest.fixture(autouse=True) + def local_preflight_catalog(self, monkeypatch): + """Validate against the complete conversion fixture without a live server.""" + from copy import deepcopy + + monkeypatch.setattr("comfy_cli.command.run._fetch_object_info", lambda *a, **k: deepcopy(self.OBJECT_INFO)) + + def unexpected_catalog_request(*args, **kwargs): + pytest.fail("unexpected real catalog request; mock the specific object_info transport") + + monkeypatch.setattr("comfy_cli.http._PLAIN_OPENER.open", unexpected_catalog_request) + monkeypatch.setattr("comfy_cli.cql.engine._load_from_target", unexpected_catalog_request) + # The conversion success fixture must also be an executable graph: # PreviewImage consumes IMAGE, not an EmptyLatentImage's LATENT output. UI = { From fde569dc1a9170c58282c76e0ef959013430a971 Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Sat, 31 Oct 2026 13:56:12 -0700 Subject: [PATCH 8/9] docs: clarify saved userdata identity in changelog --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 082c498b1..0705fbec2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,7 +36,10 @@ history. `latest_version` are read back from it by name; when exactly one record by that name with matching content can't be read back they are null, with a `workflow_record_unresolved` warning, and the save still succeeds. `--json` - also carries `filename`, `size` and `modified`. A same-name save replaces the + also carries `filename`, `size` and `modified`. `saved_file_id` identifies + the actual userdata file, separately from `workflow_id`; it is null with + `saved_file_identity_unavailable` when the server write receipt cannot + certify it. A same-name save replaces the workflow, as the Cloud editor's Save does, where it used to add a second record with the same name; the new `--no-overwrite` refuses it with `workflow_exists` instead, on both routes. On Cloud `--description` is now From 736d60e47f1c68765034ac11b192b72656de5ae6 Mon Sep 17 00:00:00 2001 From: "eric.sun" Date: Mon, 2 Nov 2026 15:47:33 -0800 Subject: [PATCH 9/9] fix(workflow): clarify safe association refusal guidance --- comfy_cli/command/workflow.py | 4 ++-- comfy_cli/error_codes.py | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/comfy_cli/command/workflow.py b/comfy_cli/command/workflow.py index 85768c6a7..96905cd28 100644 --- a/comfy_cli/command/workflow.py +++ b/comfy_cli/command/workflow.py @@ -1627,7 +1627,7 @@ def _cloud_delete(renderer, target, workflow_id: str) -> None: renderer.error( code="workflow_filename_ambiguous", message="the record name would be normalized to a different sidebar filename", - hint="inspect and remove the intended file in the Cloud sidebar before deleting its record", + hint="inspect the record and sidebar file; verify the name, content, and ownership before any manual cleanup", details={"workflow_id": workflow_id, "filename": key}, ) raise typer.Exit(code=1) @@ -1659,7 +1659,7 @@ def _cloud_delete(renderer, target, workflow_id: str) -> None: code="workflow_filename_ambiguous", message=f"cannot safely associate sidebar file {key!r} with record {workflow_id!r}", hint="inspect same-name records with `comfy --json workflow list --name `; " - "remove the intended file in the Cloud sidebar before deleting its record", + "verify the file name, content, and ownership before any manual cleanup", details={"workflow_id": workflow_id, "filename": key}, ) raise typer.Exit(code=1) diff --git a/comfy_cli/error_codes.py b/comfy_cli/error_codes.py index 2e2b53006..e15cf9dde 100644 --- a/comfy_cli/error_codes.py +++ b/comfy_cli/error_codes.py @@ -175,9 +175,9 @@ class ErrorCode: ), ErrorCode( "workflow_filename_ambiguous", - "Cloud `workflow delete` found a sidebar file but could not safely associate it with the requested " - "record (duplicate names or an unresolved lookup). Nothing was deleted.", - "inspect same-name records; remove the intended file in the Cloud sidebar before deleting its record", + "Cloud `workflow delete` could not safely associate a sidebar filename or file with the requested record " + "because its name, content, or ownership could not be verified. Nothing was deleted.", + "inspect the record and sidebar file; verify the name, content, and ownership before any manual cleanup", ), ErrorCode( "workflow_delete_incomplete",