Skip to content
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ history.

### Fixed

- `comfy build push --dry-run` now runs the push's registry-pin check, so a pin the builder cannot place fails the dry run with the push's own `build_registry_pin_missing` error instead of passing it. A version the registry has Flagged was the common case: the dry run passed, and the push was refused only after the plan had been disclosed. The check asks the builder's snapshot importer to place each public pack, a read that writes nothing, and the dry run still uploads and saves nothing. The `--json` payload of a push and a dry run carries `public_pins_checked`, the number of public pins the builder placed (0 when the spec has none and the builder was not asked), so a script can tell a checked pin set from a spec with nothing to check. A spec that pins a public pack now needs sign-in for its dry run (`build_not_signed_in` otherwise); a spec whose packs are all local still sends no request. Push and dry run also refuse when the registry did not answer for a pack (the importer's `unverifiedPins`), instead of treating the unchecked pin as resolved; refuse with `build_spec_invalid`, before sending anything, a `repository` that is not a public GitHub address (`https://github.com/<org>/<repo>`, `git@github.com:<org>/<repo>.git` or `ssh://git@github.com/<org>/<repo>`), so one that carries a user name or token, does not parse, or names another host never leaves the machine; and report a builder response that times out or drops mid-body as `build_builder_error` instead of an internal error.

- Parallel build and deploy requests rejected on an old access token now adopt a peer's refreshed token under the shared refresh lock instead of rotating it again. Each rejected request retries at most once. If session recovery still fails while a refreshable sign-in remains stored, the watch reports that the remote work may continue instead of telling you to sign in again. `comfy build release create --watch`, `comfy deploy up`, `promote`, `rollback` and `comfy deploy status --watch` now end with the new code `watch_auth_lost` and exit code 75, as `deploy_watch_lost` does. Its hint names the command that reads the release or deployment again. A 401 before anything was accepted, on a workspace API key, or when no refreshable sign-in remains still reports `build_not_signed_in` or `deploy_not_signed_in`.

- `comfy update` no longer dies with a `FileNotFoundError` traceback when the
Expand Down
152 changes: 127 additions & 25 deletions comfy_cli/command/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -1879,6 +1879,97 @@ def _write_spec(renderer, path: Path, spec: dict) -> None:
raise typer.Exit(code=1) from error


def _repository_is_sendable(repository: str) -> bool:
"""Whether the pin check may send this ``repository``: only a public GitHub
form that ``_canonical_github_repository`` recognizes (``https://github.com/org/repo``,
``git@github.com:org/repo.git`` or ``ssh://git@github.com/org/repo``), with no
user name other than ssh's ``git`` and no password, query or fragment.

Anything else is refused before the request, because the builder fetches
public GitHub repositories only and refuses the rest after receipt, by which
point a token in the string has left the machine. That includes a URL that
does not parse (``https://TOKEN@[github.com/org/repo``) and a scp-style
address with a token for its user (``TOKEN@github.com:org/repo.git``): a
string that cannot be recognized as safe is not sent."""
return _canonical_github_repository(repository) is not None


def _refuse_unsendable_repositories(renderer, public_nodes: list[dict], spec_file: Path) -> None:
"""Refuse with ``build_spec_invalid`` a public pack whose ``repository`` is not a
recognized public GitHub address. It reads the spec only, so a dry run runs it
before it asks for sign-in: a bad address gets the same answer signed in or out."""
unsendable = sorted(
str(node.get("name") or node.get("id") or "-")
for node in public_nodes
if node.get("repository") is not None
and not (isinstance(node["repository"], str) and _repository_is_sendable(node["repository"]))
)
if unsendable:
Comment thread
vqt123 marked this conversation as resolved.
Resolved
renderer.error(
code="build_spec_invalid",
message="these custom nodes name a repository that is not a public GitHub address without credentials, "
"so it is never sent: " + ", ".join(unsendable),
hint="write the repository as https://github.com/<org>/<repo> or git@github.com:<org>/<repo>.git, "
"with no user name or token; the builder fetches public GitHub repositories only",
details={"path": str(spec_file)},
)
raise typer.Exit(code=1)


def _require_public_pins(renderer, client, public_nodes: list[dict], spec_file: Path) -> None:
"""Ask the builder's importer to place every public pack, and refuse with
``build_registry_pin_missing`` naming each identity it could not place: a
registry version it does not publish (a Flagged one among them), or a
repository it cannot normalize. A pack the registry never answered about
(``report.unverifiedPins``) is refused the same way: unchecked is not placed.

The importer reads the snapshot and writes nothing, which is what lets
``push --dry-run`` make the same call and refuse the same way. A lookup that
itself fails exits through ``_builder_call`` rather than passing the pins.
A ``repository`` that is not a recognized public GitHub address is refused
before anything is sent; that covers one that does not parse and one that
carries a user name or token."""
_refuse_unsendable_repositories(renderer, public_nodes, spec_file)
imported = _builder_call(
renderer,
lambda: client.resolve_snapshot(snapshot_from_definition({"customNodes": public_nodes})),
)
checked = (imported.get("definition") or {}).get("customNodes") or []
try:
missing = public_node_identities(public_nodes) - public_node_identities(
public_node_projection({"customNodes": checked})
)
except BuildSpecInvalidError as error:
renderer.error(code=error.code, message=str(error), details={"path": str(spec_file)})
raise typer.Exit(code=1) from error
if missing:
labels = sorted(f"{identity.kind}:{identity.value}@{identity.version or '-'}" for identity in missing)
renderer.error(
code="build_registry_pin_missing",
message="the builder could not resolve these custom node identities: " + ", ".join(labels),
hint="edit the spec to name a published registry version or normalized repository, or remove the node",
)
raise typer.Exit(code=1)
# The importer keeps a pack the registry did not answer for in the definition,
# so the identity check above passes it; the report is the only place that says
# nothing confirmed it.
report = imported.get("report") if isinstance(imported, dict) else None
unverified = report.get("unverifiedPins") if isinstance(report, dict) else None
if unverified:
names = (
sorted(_from_server(name) for name in unverified)
if isinstance(unverified, list)
else [_unrenderable("unverifiedPins", unverified)]
)
renderer.error(
code="build_registry_pin_missing",
message="the registry did not answer for these custom nodes, so their pins were not checked: "
+ ", ".join(names),
hint="retry when the Comfy Registry is reachable; nothing was uploaded or saved",
)
raise typer.Exit(code=1)


@app.command("push", help="Push the local comfy-build spec to the builder.")
@tracking.track_command("build")
def push_cmd(
Expand Down Expand Up @@ -1912,7 +2003,13 @@ def push_cmd(
help="With --release, cut the release even though the save warned about a model link.",
),
] = False,
dry_run: Annotated[bool, typer.Option("--dry-run", help="Compute uploads locally; send no HTTP requests.")] = False,
dry_run: Annotated[
bool,
typer.Option(
"--dry-run",
help="Compute uploads locally and check public custom node pins with the builder; upload and save nothing.",
),
] = False,
models_dir: Annotated[
str | None,
typer.Option("--models-dir", help="Models folder used to resolve model localPath values."),
Expand All @@ -1927,7 +2024,7 @@ def push_cmd(
if release and dry_run:
renderer.error(
code="build_missing_input",
message="--release cuts a release from a real push, and --dry-run sends nothing.",
message="--release cuts a release from a real push, and --dry-run saves nothing.",
hint="drop --dry-run to cut the release, or drop --release to preview the push",
details={"conflict": ["--release", "--dry-run"]},
)
Expand Down Expand Up @@ -2008,15 +2105,32 @@ def push_cmd(
if reported:
payload["skipped_symlinks"] = reported
if dry_run:
# The pin check is the one question a dry run asks the builder: it is a
# read, it costs nothing, and it is the refusal a push otherwise meets
# only after the plan was disclosed. A spec without a public pin asks
# nothing, so it needs no sign-in.
public_nodes = public_node_projection(preparation.definition)
if public_nodes:
_refuse_unsendable_repositories(renderer, public_nodes, paths.spec_file)
_require_public_pins(renderer, _builder_client(renderer, builder_url), public_nodes, paths.spec_file)
payload["public_pins_checked"] = len(public_nodes)
# The envelope is the whole answer and prints nothing in pretty mode, so a
# person gets the real push's opening line and word that nothing moved.
# "Already held" is what the spec records; the builder, never asked,
# may hold more.
if renderer.is_pretty():
renderer.info(plan_line(len(uploads), payload["upload_bytes"], already_held_count(preparation)))
renderer.info(
"--dry-run: nothing was sent; the builder may already hold more of these than the spec records."
)
if public_nodes:
count = len(public_nodes)
renderer.info(f"The builder resolved {count} public custom node pin{'' if count == 1 else 's'}.")
renderer.info(
"--dry-run: nothing was uploaded or saved; the builder may already hold more of these "
"than the spec records."
)
else:
renderer.info(
"--dry-run: nothing was sent; the builder may already hold more of these than the spec records."
)
if _has_models(spec):
renderer.info(f"--dry-run reads no folder list from the builder, so {_FOLDER_CASE_UNCHECKED}.")
renderer.emit(payload, command="build push", changed=False)
Comment thread
vqt123 marked this conversation as resolved.
Resolved
Expand All @@ -2033,26 +2147,8 @@ def push_cmd(

public_nodes = public_node_projection(preparation.definition)
if public_nodes:
imported = _builder_call(
renderer,
lambda: client.resolve_snapshot(snapshot_from_definition({"customNodes": public_nodes})),
)
checked = (imported.get("definition") or {}).get("customNodes") or []
try:
missing = public_node_identities(public_nodes) - public_node_identities(
public_node_projection({"customNodes": checked})
)
except BuildSpecInvalidError as error:
renderer.error(code=error.code, message=str(error), details={"path": str(paths.spec_file)})
raise typer.Exit(code=1) from error
if missing:
labels = sorted(f"{identity.kind}:{identity.value}@{identity.version or '-'}" for identity in missing)
renderer.error(
code="build_registry_pin_missing",
message="the builder could not resolve these custom node identities: " + ", ".join(labels),
hint="edit the spec to name a published registry version or normalized repository, or remove the node",
)
raise typer.Exit(code=1)
_require_public_pins(renderer, client, public_nodes, paths.spec_file)
payload["public_pins_checked"] = len(public_nodes)

# Said before the first byte moves, and said even when nothing will: a
# multi-GB upload is otherwise silent until it ends, and "0 files" is
Expand Down Expand Up @@ -2799,6 +2895,12 @@ def _builder_call(
except (urllib.error.URLError, requests.RequestException, KeyError) as e:
_report_builder_error(renderer, e, subject, hint, models)
raise typer.Exit(code=1) from e
# A response body that stalls past the timeout or drops mid-read is raised by
# ``resp.read`` (``http.read_capped``), outside urllib's ``URLError`` wrapping of
# the request itself. Report it as the same transport failure, not a traceback.
except (TimeoutError, ConnectionError, http.client.IncompleteRead) as e:
_report_builder_error(renderer, urllib.error.URLError(e), subject, hint, models)
raise typer.Exit(code=1) from e
except ValueError as e:
renderer.error(code="build_missing_input", message=str(e))
raise typer.Exit(code=1) from e
Expand Down
6 changes: 5 additions & 1 deletion comfy_cli/error_codes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1451,7 +1451,11 @@ class ErrorCode:
"build_registry_pin_missing",
"`comfy build push` sent its identity-keyed public-node subset to the builder's snapshot importer, "
"which could not vouch for one or more pins. Pushing anyway would save a definition that cannot "
"reconstruct every requested public node.",
"reconstruct every requested public node. `push --dry-run` makes the same read-only check and "
"refuses the same way, uploading and saving nothing. A version the registry has Flagged "
"is refused here too, though the message does not say so. A pack the registry never answered for "
"(the importer's `report.unverifiedPins`) is refused with this code as well: unchecked is not placed, "
"and a retry once the registry answers can pass.",
"edit the spec to name a published registry version or normalized repository, or remove the node",
),
ErrorCode(
Expand Down
4 changes: 3 additions & 1 deletion comfy_cli/schemas/build_push.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"upload_count",
"upload_bytes",
"uploaded",
"deduped"
"deduped",
"public_pins_checked"
],
"additionalProperties": false,
"properties": {
Expand All @@ -25,6 +26,7 @@
"upload_bytes": {"type": "integer", "minimum": 0},
"uploaded": {"description": "Blobs whose bytes were transferred. Never exceeds `upload_count`: the builder answers with an id it already holds, and no upload URL, when the workspace already stored those exact bytes.", "type": "integer", "minimum": 0},
"deduped": {"description": "Blobs the builder already held, so `upload_count` was planned but not transferred. Always `upload_count - uploaded`.", "type": "integer", "minimum": 0},
"public_pins_checked": {"description": "How many public custom nodes (registry versions and GitHub repositories) the builder placed in the pin check, on a push and a dry run alike. 0 when the spec has none; the builder was then not asked. A pin it cannot place fails the command with `build_registry_pin_missing`, so every pin counted here passed.", "type": "integer", "minimum": 0},
"folder_case_checked": {
"description": "Present only when the spec has models. False when no usable folder list was read from the builder (`--dry-run`; a read that failed or named no folder), so a case variant of a folder (`Loras` for `loras`) passed unchecked; the builder refuses it at the release.",
"type": "boolean"
Expand Down
12 changes: 9 additions & 3 deletions comfy_cli/skills/comfy-build-failures/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,15 @@ can take (a model's `sourceUri`, a node's `registryVersion` or `repository`), fi
- `must set exactly one of sourceUri or blobId` — an entry has both or neither.
- `resolves to a duplicate node directory` — two entries claim one folder, so one
of them goes.
- `build_registry_pin_missing` — the builder could not place a public pack.
The message names each identity; correct the `registryVersion` against a
registry search, or remove the pack.
- `build_registry_pin_missing` — the builder could not place a public pack, or
the registry never answered for it (its `unverifiedPins`; retry later).
`push --dry-run` refuses the same way, before anything is uploaded or saved.
The message names each identity but not why. A version the registry has
Flagged lands here: check its `status` at
`https://api.comfy.org/nodes/<id>/versions`, and pin a version that is not
`NodeVersionStatusFlagged`, or the pack's `repository` and a commit `gitRef`.
Otherwise correct the `registryVersion` against a registry search, or remove
the pack.
- `build_spec_stale` — the remote moved under you, or `--id` names a Build the
spec's `syncedRevision` does not belong to. See *Revising*.

Expand Down
Loading
Loading