From b3183b568ead39387701bf4e358340fed46273f9 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 4 Nov 2026 18:47:25 -0500 Subject: [PATCH 1/6] fix(build): check public custom-node pins during push --dry-run A dry run used to pass a pin the real push then refused, most often a registry version the registry has Flagged. The dry run now asks the builder's snapshot importer to place the spec's public packs, the same read the push makes, and refuses with the push's own `build_registry_pin_missing`. Push and dry run share one function for it. Only the public packs are sent, and the dry run still uploads and saves nothing. A spec with public pins now needs sign-in for its dry run; a spec whose packs are all local still sends no request. Records the decision in ADR-BUILD-0008. Carries over #1045 by @wealthwiselabs, rebased on main. --- CHANGELOG.md | 2 + comfy_cli/command/build.py | 83 +++++++---- comfy_cli/error_codes.py | 4 +- .../skills/comfy-build-failures/SKILL.md | 9 +- comfy_cli/skills/comfy-build/SKILL.md | 20 ++- ...-run-check-public-pins-with-the-builder.md | 135 ++++++++++++++++++ tests/comfy_cli/command/build_auth_support.py | 21 ++- .../command/test_build_auth_matrix.py | 13 ++ tests/comfy_cli/command/test_build_push.py | 120 ++++++++++++++++ 9 files changed, 372 insertions(+), 35 deletions(-) create mode 100644 docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ade79741..1bb64f7a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. 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. + - UI→API conversion expands a `COMFY_DYNAMICCOMBO_V3` selector's sub-inputs in the order the workflow was SAVED with, when the saved graph records one, instead of the option's current order. An option that has since gained a diff --git a/comfy_cli/command/build.py b/comfy_cli/command/build.py index 695a3df9e..847f809a5 100644 --- a/comfy_cli/command/build.py +++ b/comfy_cli/command/build.py @@ -1879,6 +1879,37 @@ def _write_spec(renderer, path: Path, spec: dict) -> None: raise typer.Exit(code=1) from error +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. + + 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.""" + 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) + + @app.command("push", help="Push the local comfy-build spec to the builder.") @tracking.track_command("build") def push_cmd( @@ -1912,7 +1943,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."), @@ -1927,7 +1964,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"]}, ) @@ -2008,15 +2045,30 @@ 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: + _require_public_pins(renderer, _builder_client(renderer, builder_url), public_nodes, paths.spec_file) # 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) @@ -2033,26 +2085,7 @@ 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) # 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 diff --git a/comfy_cli/error_codes.py b/comfy_cli/error_codes.py index ff11c8db7..d9580bd0c 100644 --- a/comfy_cli/error_codes.py +++ b/comfy_cli/error_codes.py @@ -1442,7 +1442,9 @@ 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.", "edit the spec to name a published registry version or normalized repository, or remove the node", ), ErrorCode( diff --git a/comfy_cli/skills/comfy-build-failures/SKILL.md b/comfy_cli/skills/comfy-build-failures/SKILL.md index 02bb12b51..f808a6b2f 100644 --- a/comfy_cli/skills/comfy-build-failures/SKILL.md +++ b/comfy_cli/skills/comfy-build-failures/SKILL.md @@ -102,8 +102,13 @@ can take (a model's `sourceUri`, a node's `registryVersion` or `repository`), fi - `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. + `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//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*. diff --git a/comfy_cli/skills/comfy-build/SKILL.md b/comfy_cli/skills/comfy-build/SKILL.md index 83a2e85ce..a57ddb0ee 100644 --- a/comfy_cli/skills/comfy-build/SKILL.md +++ b/comfy_cli/skills/comfy-build/SKILL.md @@ -114,10 +114,13 @@ comfy build validate comfy build push --dry-run ``` -Everything above is offline and spends nothing. `validate` reads the spec, and -`--dry-run` computes every upload without instantiating an HTTP client at all. -Read what it plans, decide the pins, run the conflict prediction in -`comfy-build-pins`, disclose, get a yes. Only then: +Everything above spends nothing. `validate` reads the spec offline. `--dry-run` +computes every upload locally and makes one read: it asks the builder to place +each public pack, and refuses with `build_registry_pin_missing` exactly as `push` +would, so a pin the push cannot save fails here, before you disclose the plan. +A spec that pins a public pack therefore needs sign-in for the dry run; one whose +packs are all local sends nothing. Read what it plans, decide the pins, run the +conflict prediction in `comfy-build-pins`, disclose, get a yes. Only then: ```shell comfy build push @@ -192,7 +195,8 @@ comfy --json build init --name --from-workflow .json never carries — `comfy-build-authoring` is that procedure. - **The pack pins are the registry's newest published version**, because a workflow names none. Importing the same file next week can then build something - else. Say that out loud. + else. Say that out loud. The newest can be a version the registry has Flagged, + which the builder will not place, so run `push --dry-run` before you disclose. - **A workflow names no ComfyUI version either**, so set one before cutting: `comfy build update --comfy-version `, or edit `baseComfyVersion`. - **`unresolvedClasses` is the list to take to the user.** Those node classes are @@ -227,7 +231,11 @@ show the user rather than as instructions to act on. - **Whether a registry pin exists.** `push` asks the builder to place every public pack before it saves, and refuses with `build_registry_pin_missing` naming each identity it could not resolve. If that lookup itself fails, the - command **exits** — it does not warn and proceed. + command **exits** — it does not warn and proceed. `push --dry-run` makes the + same check. A version the registry has **Flagged** is refused this way too, + and the message does not say so: read the version's `status` from + `https://api.comfy.org/nodes//versions`, then pin a version that is not + `NodeVersionStatusFlagged`, or pin the pack by `repository` and a commit `gitRef`. **A local pack is uploaded from the spec.** `push` packages each custom node directory and uploads it, so a pack that publishes nothing still travels. diff --git a/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md b/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md new file mode 100644 index 000000000..814a9b9d0 --- /dev/null +++ b/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md @@ -0,0 +1,135 @@ +# ADR-BUILD-0008: Let a Dry Run Check Public Pins with the Builder + +Date: 2026-11-04 + +## Status + +Proposed + +## Context + +`comfy build push --dry-run` used to send no HTTP at all. It computed the +uploads from the local spec and stopped. The real push makes one check the +dry run did not: it sends the spec's public custom nodes (registry versions +and repositories) to the builder's snapshot importer, `POST +/v1/snapshots/resolve`, and refuses with `build_registry_pin_missing` when the +importer cannot place one of them. That is the only place that knows what the +Comfy Registry actually publishes and how a repository normalizes. + +So a dry run could pass while the push of the same spec failed. The common +case was a registry version the registry has Flagged: the dry run said +"looks good", the push showed its plan, and was then refused. A dry run that +passes something the push will refuse is not a preview. + +Making the dry run ask the builder changes what `--dry-run` promises: from "no +network, no sign-in" to "may make one authenticated read". That is a +command-level side-effect contract that scripts and agents rely on, so it is +recorded here. + +## Decision + +`comfy build push --dry-run` may make exactly one builder request, and only +for the pin check: + +- **When.** Only if the spec has at least one public custom node, meaning an + entry that is not `source: local` and names a `registryVersion` or a + `repository` (`public_node_projection`). A spec whose packs are all local + sends no request and needs no sign-in, as before. +- **What is sent.** Only the public-node projection, wrapped as a snapshot. + Local packs, models, files, workflow content and upload plans are never sent. +- **Which call.** `resolve_snapshot`, the snapshot importer. It is a read: it + returns a definition and a report, and writes nothing on the builder. The dry + run makes no other builder call. It creates no blobs, uploads nothing, saves + no build and cuts no release. It does not rewrite the local spec either. +- **Sign-in.** The request goes through the same authenticated builder client + as a push (`_builder_client`): an injected token, a Cloud token or API key + from the environment, or the stored sign-in. With none of these, a dry run + with public pins fails with `build_not_signed_in`. +- **Parity with push.** Push and dry run share one function, + `_require_public_pins`. They send the same payload, compare the same + identities, and refuse with the same `build_registry_pin_missing` code, + message and hint. A spec the dry run passes on this check is one the push + passes on this check, against the same builder state. +- **Failure is terminal.** If the lookup itself fails (network, 5xx, refused + credential), the dry run exits through `_builder_call` with the same error a + push would get. It never treats an unanswered check as a pass. +- **No invented reasons.** The importer does not say why it could not place a + pin. The CLI names the identities and does not claim "Flagged" or any other + registry status. + +The help text says "check public custom node pins with the builder; upload and +save nothing", and the `--release` / `--dry-run` conflict says the dry run +"saves nothing" instead of "sends nothing". + +## Alternatives considered + +- **Keep the dry run offline.** It keeps the old promise, but the dry run keeps + passing specs the push refuses, which is the bug. +- **Check pins only with a flag (`--dry-run --check-pins`).** Rejected because + the default dry run would still give the wrong answer, and the people and + agents who need the check are the ones who will not know to ask for it. +- **Warn instead of refusing.** Rejected because the push refuses, and a + preview that is softer than the real thing gets ignored. +- **Ask the public registry directly, without sign-in.** Rejected because it + would be a second implementation of what the importer decides. Repository + normalization and which versions the builder can place live in the builder, + and the two would drift. +- **Fall back to passing when the lookup fails.** Rejected because "could not + check" is not "checked and fine". + +## What we reject + +- Any dry-run builder call that writes: blob creation, uploads, saves, + releases, or any endpoint not documented as read-only. +- Sending anything beyond the public-node projection on a dry run. +- A builder request, or a sign-in requirement, for a spec with no public pins. +- A second copy of the pin check that can drift from the push's. +- Treating a failed or unanswered lookup as a pass. + +## Consequences + +### Positive + +- A dry run now fails on the pin the push would refuse, with the push's own + code, before anyone acts on the plan. +- One function owns the check, so push and dry run cannot drift. +- All-local specs keep a zero-request, no-sign-in dry run. + +### Negative + +- A dry run on a spec with public pins now needs sign-in and network. A CI job + that ran `--dry-run` with no credential will fail with `build_not_signed_in` + until it sets `COMFY_CLOUD_API_KEY` or drops the public pins. +- The dry run now depends on the builder being up for those specs. +- `build_registry_pin_missing` can now come from a dry run. Its meaning is + unchanged, so this stays within ADR-AUTOMATION-0003's rule that error codes + are never repurposed. + +### Known limits + +- The answer is only as fresh as the builder's view when the dry run ran. A + registry change between the dry run and the push can still make the push + refuse. +- The dry run still reads no folder list from the builder, so it does not + check model folder case. That stays as it was. + +## Validation + +- `tests/comfy_cli/command/test_build_push.py`: a dry run refuses a Flagged pin + with the push's own error; it sends only the public pins to the importer and + makes no other call; a failed lookup exits instead of passing; the pretty + output says the pins were checked and nothing was uploaded or saved. +- `tests/comfy_cli/command/test_build_auth_matrix.py` and + `build_auth_support.py`: a dry run with public pins needs a credential, and + one with only local packs sends nothing. + +## Revisit triggers + +- The builder exposes a public, unauthenticated pin-check endpoint. The dry run + could then drop the sign-in requirement. +- The importer starts returning a reason per pin it could not place. The + refusal could then name it. +- Users report CI breakage from the new sign-in requirement often enough that + an offline mode is worth adding back as an explicit option. +- The dry run needs a second builder read (for example the folder list). That + widens this boundary and needs its own decision. diff --git a/tests/comfy_cli/command/build_auth_support.py b/tests/comfy_cli/command/build_auth_support.py index fb4f02706..a726741ae 100644 --- a/tests/comfy_cli/command/build_auth_support.py +++ b/tests/comfy_cli/command/build_auth_support.py @@ -27,7 +27,6 @@ # Keyed on the URL *path* so a route carrying query parameters (`?cursor=`, # `?os=&gpu=`) still matches. _ROUTES: dict[tuple[str, str], tuple[int, JsonObject]] = { - ("POST", "/v1/snapshots/resolve"): (200, {"definition": _EMPTY_DEFINITION, "report": {}}), ("POST", "/v1/builds"): (201, {"id": BUILD_ID, "updatedAt": REVISION}), ("GET", "/v1/builds"): (200, {"builds": [{"id": BUILD_ID, "name": "Matrix"}]}), ("GET", f"/v1/builds/{BUILD_ID}"): ( @@ -99,6 +98,8 @@ def __call__( path = urlsplit(url).path if (method, path) == ("POST", "/v1/models/resolve"): return 200, {"results": _resolved_filenames(body)} + if (method, path) == ("POST", "/v1/snapshots/resolve"): + return 200, {"definition": {"models": [], "customNodes": _placed_nodes(body)}, "report": {}} route = _ROUTES.get((method, path)) if route is None: pytest.fail(f"unexpected Builder call: {method} {url}") @@ -113,6 +114,24 @@ def _resolved_filenames(body: JsonObject | None) -> list[JsonValue]: return [{"filename": filename, "candidates": []} for filename in filenames] +def _placed_nodes(body: JsonObject | None) -> list[JsonValue]: + """Every pack the snapshot names, placed as asked: the importer vouches for + each pin, so a push or dry run that sends one gets past its pin check.""" + assert body is not None + snapshot = body["snapshot"] + assert isinstance(snapshot, dict) + placed: list[JsonValue] = [] + for entry in snapshot.get("snapshots") or []: + assert isinstance(entry, dict) + for node in entry.get("customNodes") or []: + assert isinstance(node, dict) + if node["type"] == "cnr": + placed.append({"name": node["dirName"], "id": node["id"], "registryVersion": node["version"]}) + else: + placed.append({"name": node["dirName"], "repository": node["url"]}) + return placed + + def write_snapshot(root: Path) -> Path: path = root / "snapshot.json" path.write_text(json.dumps({"customNodes": [], "pipPackages": {}, "pythonVersion": "3.12"}), encoding="utf-8") diff --git a/tests/comfy_cli/command/test_build_auth_matrix.py b/tests/comfy_cli/command/test_build_auth_matrix.py index fca091c29..003a50015 100644 --- a/tests/comfy_cli/command/test_build_auth_matrix.py +++ b/tests/comfy_cli/command/test_build_auth_matrix.py @@ -53,6 +53,7 @@ class FixtureKind(Enum): VALIDATE_REMOTE_LOOKUP = "validate --remote (lookupable)" PUSH = "push" PUSH_DRY_RUN = "push --dry-run" + PUSH_DRY_RUN_PINNED = "push --dry-run (public pins)" PULL = "pull" STATUS = "status" LS = "ls" @@ -95,7 +96,10 @@ class BuildAuthCase: BuildAuthCase(FixtureKind.VALIDATE_REMOTE_ZERO, "validate", True, _ZERO_PLUS, 1), BuildAuthCase(FixtureKind.VALIDATE_REMOTE_LOOKUP, "validate", True, _ZERO_PLUS, 2), BuildAuthCase(FixtureKind.PUSH, "push", True, _ONE_PLUS), + # A dry run asks the builder only to place the spec's public pins, the read the + # push makes before it saves, so a spec without one stays signed out and silent. BuildAuthCase(FixtureKind.PUSH_DRY_RUN, "push", False, _ZERO), + BuildAuthCase(FixtureKind.PUSH_DRY_RUN_PINNED, "push", True, _ONE_PLUS, 1), BuildAuthCase(FixtureKind.PULL, "pull", True, _ONE_PLUS), BuildAuthCase(FixtureKind.STATUS, "status", True, _ONE_PLUS), BuildAuthCase(FixtureKind.LS, "ls", True, _ONE_PLUS), @@ -165,6 +169,15 @@ def _prepare(kind: FixtureKind, root: Path) -> list[str]: case FixtureKind.PUSH_DRY_RUN: write_spec(root, models=[], nodes=[]) return ["build", "push", "--dry-run", str(root)] + case FixtureKind.PUSH_DRY_RUN_PINNED: + write_spec( + root, + models=[], + nodes=[ + {"name": "registry-node", "id": "registry-node", "registryVersion": "1.0.0", "source": "registry"} + ], + ) + return ["build", "push", "--dry-run", str(root)] case FixtureKind.PULL: write_spec(root, models=[], nodes=[]) return ["build", "pull", "-y", "--id", BUILD_ID, str(root)] diff --git a/tests/comfy_cli/command/test_build_push.py b/tests/comfy_cli/command/test_build_push.py index 29d065995..fd52305d7 100644 --- a/tests/comfy_cli/command/test_build_push.py +++ b/tests/comfy_cli/command/test_build_push.py @@ -61,6 +61,7 @@ def _schema(name: str) -> JsonObject: def test_dry_run_is_signed_out_and_zero_http(workspace: Path, monkeypatch: pytest.MonkeyPatch) -> None: + """Only a public pin needs the builder, so a spec without one asks it nothing.""" # Given path = write_spec(workspace) before = path.read_bytes() @@ -294,6 +295,125 @@ def test_pin_gate_normalizes_equivalent_repository_identities(workspace: Path, m assert len(client.snapshots) == 1 +#: A pin to a version the registry has Flagged. The builder's importer cannot +#: place it, so the push refuses it. +_FLAGGED_PIN: JsonObject = { + "name": "ComfyUI-DepthAnythingV3", + "id": "ComfyUI-DepthAnythingV3", + "registryVersion": "0.1.19", + "source": "registry", +} + +_REGISTRY_PIN: JsonObject = { + "name": "registry-node", + "id": "registry-node", + "registryVersion": "1.0.0", + "source": "registry", +} + + +class _FlaggedImporter(RecordingBuilder): + """The importer's answer for a Flagged version, in the shape the live builder + sends: the pack is left out of the definition and named in the report.""" + + def resolve_snapshot(self, snapshot: JsonObject) -> JsonObject: + super().resolve_snapshot(snapshot) + return { + "definition": {}, + "report": {"notInRegistry": [_FLAGGED_PIN["id"]], "unresolvedNodes": [_FLAGGED_PIN["id"]]}, + } + + +def test_a_dry_run_refuses_a_flagged_pin_with_the_push_s_own_error( + tmp_path: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + """A dry run is the free check before disclosing and spending, so it must + refuse a pin the builder cannot place the way the push does, not pass it.""" + # Given + pushed_root = make_workspace(tmp_path / "push") + write_spec(pushed_root, models=[], nodes=[_FLAGGED_PIN]) + pushed = _FlaggedImporter() + _install_client(monkeypatch, pushed) + push = invoke_push(pushed_root) + + dry_root = make_workspace(tmp_path / "dry-run") + spec = write_spec(dry_root, models=[], nodes=[_FLAGGED_PIN]) + before = spec.read_bytes() + dry = _FlaggedImporter() + _install_client(monkeypatch, dry) + + # When + result = invoke_push(dry_root, "--dry-run") + + # Then + assert (push.exit_code, result.exit_code) == (1, 1) + error = envelope(result)["error"] + assert error == envelope(push)["error"] + assert error["code"] == "build_registry_pin_missing" + assert "registry:ComfyUI-DepthAnythingV3@0.1.19" in error["message"] + assert [call["method"] for call in dry.calls] == ["resolve_snapshot"] + assert spec.read_bytes() == before + + +def test_a_dry_run_asks_the_builder_only_to_place_its_public_pins( + workspace: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + # Given + path = write_spec(workspace, nodes=[local_node(), _REGISTRY_PIN]) + before = path.read_bytes() + client = RecordingBuilder() + _install_client(monkeypatch, client) + + # When + result = invoke_push(workspace, "--dry-run") + + # Then + assert result.exit_code == 0, result.stderr + assert [call["method"] for call in client.calls] == ["resolve_snapshot"] + sent = client.snapshots[0]["snapshots"][0]["customNodes"] + assert [(node["id"], node["version"]) for node in sent] == [("registry-node", "1.0.0")] + data = envelope(result)["data"] + assert (data["dry_run"], data["upload_count"], data["uploaded"]) == (True, 2, 0) + assert path.read_bytes() == before + + +def test_a_dry_run_whose_pin_lookup_fails_exits_rather_than_passing( + workspace: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + # Given + write_spec(workspace, models=[], nodes=[_REGISTRY_PIN]) + client = RecordingBuilder() + + def unreachable(snapshot: JsonObject) -> JsonObject: + raise urllib.error.URLError("connection refused") + + monkeypatch.setattr(client, "resolve_snapshot", unreachable) + _install_client(monkeypatch, client) + + # When + result = invoke_push(workspace, "--dry-run") + + # Then + assert result.exit_code == 1 + assert envelope(result)["error"]["code"] == "build_builder_error" + + +def test_a_dry_run_tells_a_person_it_checked_the_public_pins(workspace: Path, monkeypatch: pytest.MonkeyPatch) -> None: + # Given + write_spec(workspace, nodes=[local_node(), _REGISTRY_PIN]) + _install_client(monkeypatch, RecordingBuilder()) + + # When + result = invoke_push(workspace, "--dry-run", agentic=False) + + # Then + assert result.exit_code == 0, result.output + text = " ".join(result.stdout.split()) + assert "The builder resolved 1 public custom node pin." in text + assert "nothing was uploaded or saved" in text + assert "nothing was sent" not in text + + def test_a_skipped_symlink_is_named_on_stderr_and_carried_in_the_payload( workspace: Path, monkeypatch: pytest.MonkeyPatch ) -> None: From 04f9502a67cd2fb913806a68ae0d5dd0ad64606b Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 4 Nov 2026 19:58:45 -0500 Subject: [PATCH 2/6] fix(build): refuse unverified pins and credentialed repositories; wrap body-read failures - The pin check refuses a report listing unverifiedPins with build_registry_pin_missing: the importer keeps those packs in the definition unchecked, so the identity comparison alone passed them. - A repository URL with a user name or token is refused with build_spec_invalid before the snapshot request, so it never leaves the machine. - _builder_call reports TimeoutError, ConnectionError and IncompleteRead from a response body read as the builder transport error instead of an internal error. --- CHANGELOG.md | 2 +- comfy_cli/command/build.py | 55 ++++++++++- comfy_cli/error_codes.py | 4 +- .../skills/comfy-build-failures/SKILL.md | 3 +- comfy_cli/skills/comfy-build/SKILL.md | 8 +- ...-run-check-public-pins-with-the-builder.md | 15 ++- tests/comfy_cli/command/test_build_push.py | 97 +++++++++++++++++++ 7 files changed, 173 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1bb64f7a0..6d58855f3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,7 +65,7 @@ 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. 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. +- `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. 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 a `repository` URL that carries a user name or token with `build_spec_invalid` before sending it; and report a builder response that times out or drops mid-body as `build_builder_error` instead of an internal error. - UI→API conversion expands a `COMFY_DYNAMICCOMBO_V3` selector's sub-inputs in the order the workflow was SAVED with, when the saved graph records one, diff --git a/comfy_cli/command/build.py b/comfy_cli/command/build.py index 847f809a5..ae8dd1bf7 100644 --- a/comfy_cli/command/build.py +++ b/comfy_cli/command/build.py @@ -1879,15 +1879,42 @@ def _write_spec(renderer, path: Path, spec: dict) -> None: raise typer.Exit(code=1) from error +def _repository_has_credentials(repository: str) -> bool: + """A repository URL with a password or a user name other than ssh's ``git`` + (``https://TOKEN@github.com/…``). The builder fetches public repositories only + and refuses these after receipt, so the credential must not leave the machine.""" + try: + parts = urlsplit(repository.strip()) + except ValueError: + return False + return parts.password is not None or (parts.username is not None and parts.username != "git") + + 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. + 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.""" + itself fails exits through ``_builder_call`` rather than passing the pins. + A repository URL that carries credentials is refused before anything is sent.""" + credentialed = sorted( + str(node.get("name") or node.get("id") or "-") + for node in public_nodes + if isinstance(node.get("repository"), str) and _repository_has_credentials(node["repository"]) + ) + if credentialed: + renderer.error( + code="build_spec_invalid", + message="these custom nodes name a repository URL that carries credentials, which is never sent: " + + ", ".join(credentialed), + hint="remove the user name or token from the repository URL; the builder fetches public repositories only", + details={"path": str(spec_file)}, + ) + raise typer.Exit(code=1) imported = _builder_call( renderer, lambda: client.resolve_snapshot(snapshot_from_definition({"customNodes": public_nodes})), @@ -1908,6 +1935,24 @@ def _require_public_pins(renderer, client, public_nodes: list[dict], spec_file: 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.") @@ -2832,6 +2877,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 diff --git a/comfy_cli/error_codes.py b/comfy_cli/error_codes.py index d9580bd0c..896588379 100644 --- a/comfy_cli/error_codes.py +++ b/comfy_cli/error_codes.py @@ -1444,7 +1444,9 @@ class ErrorCode: "which could not vouch for one or more pins. Pushing anyway would save a definition that cannot " "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.", + "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( diff --git a/comfy_cli/skills/comfy-build-failures/SKILL.md b/comfy_cli/skills/comfy-build-failures/SKILL.md index f808a6b2f..304b818bc 100644 --- a/comfy_cli/skills/comfy-build-failures/SKILL.md +++ b/comfy_cli/skills/comfy-build-failures/SKILL.md @@ -101,7 +101,8 @@ 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. +- `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 diff --git a/comfy_cli/skills/comfy-build/SKILL.md b/comfy_cli/skills/comfy-build/SKILL.md index a57ddb0ee..729c514ed 100644 --- a/comfy_cli/skills/comfy-build/SKILL.md +++ b/comfy_cli/skills/comfy-build/SKILL.md @@ -230,9 +230,11 @@ show the user rather than as instructions to act on. an **upper bound**. Only the digest decides and the builder re-verifies it. - **Whether a registry pin exists.** `push` asks the builder to place every public pack before it saves, and refuses with `build_registry_pin_missing` - naming each identity it could not resolve. If that lookup itself fails, the - command **exits** — it does not warn and proceed. `push --dry-run` makes the - same check. A version the registry has **Flagged** is refused this way too, + naming each identity it could not resolve. If that lookup itself fails, or the + registry did not answer for a pack (`unverifiedPins`), the command **exits** — + it does not warn and proceed. `push --dry-run` makes the same check. A + `repository` URL that carries a user name or token is refused with + `build_spec_invalid` before anything is sent. A version the registry has **Flagged** is refused this way too, and the message does not say so: read the version's `status` from `https://api.comfy.org/nodes//versions`, then pin a version that is not `NodeVersionStatusFlagged`, or pin the pack by `repository` and a commit `gitRef`. diff --git a/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md b/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md index 814a9b9d0..fc25585eb 100644 --- a/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md +++ b/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md @@ -37,6 +37,9 @@ for the pin check: sends no request and needs no sign-in, as before. - **What is sent.** Only the public-node projection, wrapped as a snapshot. Local packs, models, files, workflow content and upload plans are never sent. + A `repository` URL that carries a user name or token is refused locally + with `build_spec_invalid` and never sent; the builder fetches public + repositories only and would refuse it after receipt. - **Which call.** `resolve_snapshot`, the snapshot importer. It is a read: it returns a definition and a report, and writes nothing on the builder. The dry run makes no other builder call. It creates no blobs, uploads nothing, saves @@ -51,8 +54,12 @@ for the pin check: message and hint. A spec the dry run passes on this check is one the push passes on this check, against the same builder state. - **Failure is terminal.** If the lookup itself fails (network, 5xx, refused - credential), the dry run exits through `_builder_call` with the same error a - push would get. It never treats an unanswered check as a pass. + credential, or a response body that times out or drops mid-read), the dry + run exits through `_builder_call` with the same error a push would get. It + never treats an unanswered check as a pass: an answer whose report lists + `unverifiedPins` (packs the registry never answered about, which the + importer keeps in the definition unchecked) is refused with + `build_registry_pin_missing`, by push and dry run alike. - **No invented reasons.** The importer does not say why it could not place a pin. The CLI names the identities and does not claim "Flagged" or any other registry status. @@ -117,7 +124,9 @@ save nothing", and the `--release` / `--dry-run` conflict says the dry run - `tests/comfy_cli/command/test_build_push.py`: a dry run refuses a Flagged pin with the push's own error; it sends only the public pins to the importer and - makes no other call; a failed lookup exits instead of passing; the pretty + makes no other call; a failed lookup, a stalled response body, or a report + with `unverifiedPins` exits instead of passing; a credential-bearing + repository is refused before any request; the pretty output says the pins were checked and nothing was uploaded or saved. - `tests/comfy_cli/command/test_build_auth_matrix.py` and `build_auth_support.py`: a dry run with public pins needs a credential, and diff --git a/tests/comfy_cli/command/test_build_push.py b/tests/comfy_cli/command/test_build_push.py index fd52305d7..3c98a2a66 100644 --- a/tests/comfy_cli/command/test_build_push.py +++ b/tests/comfy_cli/command/test_build_push.py @@ -398,6 +398,103 @@ def unreachable(snapshot: JsonObject) -> JsonObject: assert envelope(result)["error"]["code"] == "build_builder_error" +@pytest.mark.parametrize( + "failure", + [TimeoutError("The read operation timed out"), ConnectionResetError(54, "reset"), http.client.IncompleteRead(b"{")], + ids=["timeout", "reset", "incomplete"], +) +def test_a_pin_lookup_whose_response_body_fails_is_a_transport_error( + workspace: Path, monkeypatch: pytest.MonkeyPatch, failure: Exception +) -> None: + """``read_capped`` raises these from ``resp.read``, past urllib's URLError + wrapping, so they reach ``_builder_call`` bare.""" + # Given + write_spec(workspace, models=[], nodes=[_REGISTRY_PIN]) + client = RecordingBuilder() + + def stalled(snapshot: JsonObject) -> JsonObject: + raise failure + + monkeypatch.setattr(client, "resolve_snapshot", stalled) + _install_client(monkeypatch, client) + + # When + result = invoke_push(workspace, "--dry-run") + + # Then + assert result.exit_code == 1 + assert envelope(result)["error"]["code"] == "build_builder_error" + + +class _UnansweredImporter(RecordingBuilder): + """The registry did not answer: the importer keeps the pin in the definition + unchanged and names it in ``report.unverifiedPins``, with HTTP 200.""" + + def resolve_snapshot(self, snapshot: JsonObject) -> JsonObject: + answer = super().resolve_snapshot(snapshot) + return {**answer, "report": {"unverifiedPins": [_REGISTRY_PIN["id"]]}} + + +def test_unverified_pins_are_refused_by_push_and_dry_run_alike(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None: + # Given + pushed_root = make_workspace(tmp_path / "push") + write_spec(pushed_root, models=[], nodes=[_REGISTRY_PIN]) + pushed = _UnansweredImporter() + _install_client(monkeypatch, pushed) + push = invoke_push(pushed_root) + + dry_root = make_workspace(tmp_path / "dry-run") + write_spec(dry_root, models=[], nodes=[_REGISTRY_PIN]) + dry = _UnansweredImporter() + _install_client(monkeypatch, dry) + + # When + result = invoke_push(dry_root, "--dry-run", agentic=False) + dry_json = invoke_push(dry_root, "--dry-run") + + # Then + assert (push.exit_code, result.exit_code, dry_json.exit_code) == (1, 1, 1) + error = envelope(dry_json)["error"] + assert error == envelope(push)["error"] + assert error["code"] == "build_registry_pin_missing" + assert "registry-node" in error["message"] and "not checked" in error["message"] + assert _calls(pushed, "create_build") == [] + assert "The builder resolved" not in result.stdout + + +@pytest.mark.parametrize( + "repository", + ["https://ghp_TOKENSECRET@github.com/org/repo", "https://x-access-token:ghp_TOKENSECRET@github.com/org/repo"], +) +@pytest.mark.parametrize("dry_run", [True, False]) +def test_a_repository_url_with_credentials_is_refused_before_any_request( + workspace: Path, monkeypatch: pytest.MonkeyPatch, repository: str, dry_run: bool +) -> None: + # Given + node = {"name": "private-node", "source": "git", "repository": repository, "gitRef": "main"} + write_spec(workspace, models=[], nodes=[node]) + client = RecordingBuilder() + _install_client(monkeypatch, client) + + # When + result = invoke_push(workspace, *(["--dry-run"] if dry_run else [])) + + # Then + assert result.exit_code == 1 + error = envelope(result)["error"] + assert error["code"] == "build_spec_invalid" + assert "private-node" in error["message"] + assert client.calls == [] + assert "ghp_TOKENSECRET" not in result.output + + +def test_an_ssh_git_user_is_not_a_credential() -> None: + assert not build._repository_has_credentials("ssh://git@github.com/org/repo") + assert not build._repository_has_credentials("git@github.com:org/repo.git") + assert not build._repository_has_credentials("https://github.com/org/repo") + assert build._repository_has_credentials("https://user@github.com/org/repo") + + def test_a_dry_run_tells_a_person_it_checked_the_public_pins(workspace: Path, monkeypatch: pytest.MonkeyPatch) -> None: # Given write_spec(workspace, nodes=[local_node(), _REGISTRY_PIN]) From 5ec0db50d3f9191ad842a96345fbaa33614050a6 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 4 Nov 2026 20:00:52 -0500 Subject: [PATCH 3/6] docs(adr): rename BUILD-0008 to BUILD-VALIDATION-0008 so the id does not read as a ticket id --- ...ON-0008-let-a-dry-run-check-public-pins-with-the-builder.md} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename docs/adr/{BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md => BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md} (98%) diff --git a/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md similarity index 98% rename from docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md rename to docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md index fc25585eb..f7f8cf8c5 100644 --- a/docs/adr/BUILD-0008-let-a-dry-run-check-public-pins-with-the-builder.md +++ b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md @@ -1,4 +1,4 @@ -# ADR-BUILD-0008: Let a Dry Run Check Public Pins with the Builder +# ADR-BUILD-VALIDATION-0008: Let a Dry Run Check Public Pins with the Builder Date: 2026-11-04 From 42efa27028d1a6f1eac3de50edb753b12971f232 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 4 Nov 2026 21:06:14 -0500 Subject: [PATCH 4/6] fix(build): send only recognized public GitHub repositories to the pin check The credential guard read a URL parse failure as "no credentials" and could not see a user name in scp-style addresses, so `https://TOKEN@[github.com/org/repo` and `TOKEN@github.com:org/repo.git` were sent to the builder by push and push --dry-run. The pin check now sends a repository only when _canonical_github_repository recognizes it as a public GitHub address (https, git@github.com: or ssh://git@github.com, no user name other than git, no password, query, fragment or port). Anything else, including a string that does not parse, is refused with build_spec_invalid before any request. --- CHANGELOG.md | 2 +- comfy_cli/command/build.py | 40 +++++++++------ comfy_cli/skills/comfy-build/SKILL.md | 6 ++- ...-run-check-public-pins-with-the-builder.md | 18 +++++-- tests/comfy_cli/command/test_build_push.py | 51 ++++++++++++++++--- 5 files changed, 85 insertions(+), 32 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d58855f3..57b022e48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,7 +65,7 @@ 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. 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 a `repository` URL that carries a user name or token with `build_spec_invalid` before sending it; and report a builder response that times out or drops mid-body as `build_builder_error` instead of an internal error. +- `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. 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//`, `git@github.com:/.git` or `ssh://git@github.com//`), 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. - UI→API conversion expands a `COMFY_DYNAMICCOMBO_V3` selector's sub-inputs in the order the workflow was SAVED with, when the saved graph records one, diff --git a/comfy_cli/command/build.py b/comfy_cli/command/build.py index ae8dd1bf7..220412e3c 100644 --- a/comfy_cli/command/build.py +++ b/comfy_cli/command/build.py @@ -1879,15 +1879,19 @@ def _write_spec(renderer, path: Path, spec: dict) -> None: raise typer.Exit(code=1) from error -def _repository_has_credentials(repository: str) -> bool: - """A repository URL with a password or a user name other than ssh's ``git`` - (``https://TOKEN@github.com/…``). The builder fetches public repositories only - and refuses these after receipt, so the credential must not leave the machine.""" - try: - parts = urlsplit(repository.strip()) - except ValueError: - return False - return parts.password is not None or (parts.username is not None and parts.username != "git") +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 _require_public_pins(renderer, client, public_nodes: list[dict], spec_file: Path) -> None: @@ -1900,18 +1904,22 @@ def _require_public_pins(renderer, client, public_nodes: list[dict], spec_file: 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 URL that carries credentials is refused before anything is sent.""" - credentialed = sorted( + 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.""" + unsendable = sorted( str(node.get("name") or node.get("id") or "-") for node in public_nodes - if isinstance(node.get("repository"), str) and _repository_has_credentials(node["repository"]) + if node.get("repository") is not None + and not (isinstance(node["repository"], str) and _repository_is_sendable(node["repository"])) ) - if credentialed: + if unsendable: renderer.error( code="build_spec_invalid", - message="these custom nodes name a repository URL that carries credentials, which is never sent: " - + ", ".join(credentialed), - hint="remove the user name or token from the repository URL; the builder fetches public repositories only", + 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// or git@github.com:/.git, " + "with no user name or token; the builder fetches public GitHub repositories only", details={"path": str(spec_file)}, ) raise typer.Exit(code=1) diff --git a/comfy_cli/skills/comfy-build/SKILL.md b/comfy_cli/skills/comfy-build/SKILL.md index 729c514ed..32f1878bb 100644 --- a/comfy_cli/skills/comfy-build/SKILL.md +++ b/comfy_cli/skills/comfy-build/SKILL.md @@ -233,8 +233,10 @@ show the user rather than as instructions to act on. naming each identity it could not resolve. If that lookup itself fails, or the registry did not answer for a pack (`unverifiedPins`), the command **exits** — it does not warn and proceed. `push --dry-run` makes the same check. A - `repository` URL that carries a user name or token is refused with - `build_spec_invalid` before anything is sent. A version the registry has **Flagged** is refused this way too, + `repository` that is not a public GitHub address (`https://github.com//`, + `git@github.com:/.git` or `ssh://git@github.com//`, with no + user name or token) is refused with `build_spec_invalid` before anything is + sent, and so is one that does not parse. A version the registry has **Flagged** is refused this way too, and the message does not say so: read the version's `status` from `https://api.comfy.org/nodes//versions`, then pin a version that is not `NodeVersionStatusFlagged`, or pin the pack by `repository` and a commit `gitRef`. diff --git a/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md index f7f8cf8c5..4f768876e 100644 --- a/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md +++ b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md @@ -37,9 +37,16 @@ for the pin check: sends no request and needs no sign-in, as before. - **What is sent.** Only the public-node projection, wrapped as a snapshot. Local packs, models, files, workflow content and upload plans are never sent. - A `repository` URL that carries a user name or token is refused locally - with `build_spec_invalid` and never sent; the builder fetches public - repositories only and would refuse it after receipt. + Each `repository` must be a public GitHub address the CLI recognizes + (`https://github.com//`, `git@github.com:/.git` or + `ssh://git@github.com//`), with no user name other than ssh's + `git`, no password, query or fragment. Any other `repository` is refused + locally with `build_spec_invalid` and never sent: one that carries a token, + one that does not parse (`https://TOKEN@[github.com/org/repo`), and a + scp-style one with a token for its user (`TOKEN@github.com:org/repo.git`). + The builder fetches public GitHub repositories only and would refuse the + rest after receipt, when a token in the string has already left the + machine. - **Which call.** `resolve_snapshot`, the snapshot importer. It is a read: it returns a definition and a report, and writes nothing on the builder. The dry run makes no other builder call. It creates no blobs, uploads nothing, saves @@ -125,8 +132,9 @@ save nothing", and the `--release` / `--dry-run` conflict says the dry run - `tests/comfy_cli/command/test_build_push.py`: a dry run refuses a Flagged pin with the push's own error; it sends only the public pins to the importer and makes no other call; a failed lookup, a stalled response body, or a report - with `unverifiedPins` exits instead of passing; a credential-bearing - repository is refused before any request; the pretty + with `unverifiedPins` exits instead of passing; a repository that carries a + token, does not parse, or is scp-style with a token user is refused before + any request; the pretty output says the pins were checked and nothing was uploaded or saved. - `tests/comfy_cli/command/test_build_auth_matrix.py` and `build_auth_support.py`: a dry run with public pins needs a credential, and diff --git a/tests/comfy_cli/command/test_build_push.py b/tests/comfy_cli/command/test_build_push.py index 3c98a2a66..307607779 100644 --- a/tests/comfy_cli/command/test_build_push.py +++ b/tests/comfy_cli/command/test_build_push.py @@ -278,13 +278,13 @@ def test_pin_gate_normalizes_equivalent_repository_identities(workspace: Path, m { "name": "repo-node", "source": "git", - "repository": "git@Example.COM:Owner/Repo.git", + "repository": "git@GitHub.COM:Owner/Repo.git", "gitRef": "main", } ], ) client = RecordingBuilder() - client.checked_nodes = [{"name": "repo-node", "repository": "https://example.com/Owner/Repo/"}] + client.checked_nodes = [{"name": "repo-node", "repository": "https://github.com/Owner/Repo/"}] _install_client(monkeypatch, client) # When @@ -464,7 +464,14 @@ def test_unverified_pins_are_refused_by_push_and_dry_run_alike(tmp_path: Path, m @pytest.mark.parametrize( "repository", - ["https://ghp_TOKENSECRET@github.com/org/repo", "https://x-access-token:ghp_TOKENSECRET@github.com/org/repo"], + [ + "https://ghp_TOKENSECRET@github.com/org/repo", + "https://x-access-token:ghp_TOKENSECRET@github.com/org/repo", + # Does not parse (unmatched bracket): a parse failure is a refusal, not "no credentials". + "https://ghp_TOKENSECRET@[github.com/org/repo", + # scp-style, so there is no URL authority to read a user name from. + "ghp_TOKENSECRET@github.com:org/repo.git", + ], ) @pytest.mark.parametrize("dry_run", [True, False]) def test_a_repository_url_with_credentials_is_refused_before_any_request( @@ -488,11 +495,39 @@ def test_a_repository_url_with_credentials_is_refused_before_any_request( assert "ghp_TOKENSECRET" not in result.output -def test_an_ssh_git_user_is_not_a_credential() -> None: - assert not build._repository_has_credentials("ssh://git@github.com/org/repo") - assert not build._repository_has_credentials("git@github.com:org/repo.git") - assert not build._repository_has_credentials("https://github.com/org/repo") - assert build._repository_has_credentials("https://user@github.com/org/repo") +@pytest.mark.parametrize( + "repository", + [ + "https://github.com/org/repo", + "https://github.com/org/repo.git", + "https://github.com/org/repo/", + "git@github.com:org/repo.git", + "ssh://git@github.com/org/repo", + ], +) +def test_a_public_github_repository_is_sendable(repository: str) -> None: + assert build._repository_is_sendable(repository) + + +@pytest.mark.parametrize( + "repository", + [ + "https://user@github.com/org/repo", + "https://user:TOKEN@github.com/org/repo", + "https://TOKEN@[github.com/org/repo", + "TOKEN@github.com:org/repo.git", + "ssh://git:TOKEN@github.com/org/repo", + "git@github.com:TOKEN@org/repo.git", + "https://github.com/org/repo?token=TOKEN", + "https://github.com/org/repo#TOKEN", + "https://github.com:8443/org/repo", + "http://github.com/org/repo", + "https://example.com/org/repo", + "https://github.com/org", + ], +) +def test_a_repository_that_is_not_a_public_github_address_is_not_sendable(repository: str) -> None: + assert not build._repository_is_sendable(repository) def test_a_dry_run_tells_a_person_it_checked_the_public_pins(workspace: Path, monkeypatch: pytest.MonkeyPatch) -> None: From b2a0253ec1c317a0eb587b78f5c3fb9c227492b7 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 4 Nov 2026 22:25:26 -0500 Subject: [PATCH 5/6] feat(build): report public_pins_checked in the push and dry-run payload A dry run's JSON envelope was the same whether the builder checked public pins or the spec had none, so a script could not tell the two apart. Push and dry run now carry public_pins_checked: how many public pins the builder placed, 0 when there were none and the builder was not asked. --- CHANGELOG.md | 2 +- comfy_cli/command/build.py | 2 ++ comfy_cli/schemas/build_push.json | 4 +++- comfy_cli/skills/comfy-build/SKILL.md | 3 ++- ...-run-check-public-pins-with-the-builder.md | 5 +++++ tests/comfy_cli/command/test_build_push.py | 22 +++++++++++++++++++ 6 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57b022e48..0ec780b04 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -65,7 +65,7 @@ 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. 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//`, `git@github.com:/.git` or `ssh://git@github.com//`), 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. +- `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//`, `git@github.com:/.git` or `ssh://git@github.com//`), 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. - UI→API conversion expands a `COMFY_DYNAMICCOMBO_V3` selector's sub-inputs in the order the workflow was SAVED with, when the saved graph records one, diff --git a/comfy_cli/command/build.py b/comfy_cli/command/build.py index 220412e3c..1220fa5a7 100644 --- a/comfy_cli/command/build.py +++ b/comfy_cli/command/build.py @@ -2105,6 +2105,7 @@ def push_cmd( public_nodes = public_node_projection(preparation.definition) if public_nodes: _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, @@ -2139,6 +2140,7 @@ def push_cmd( public_nodes = public_node_projection(preparation.definition) if public_nodes: _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 diff --git a/comfy_cli/schemas/build_push.json b/comfy_cli/schemas/build_push.json index bf8526ad7..a496bc37c 100644 --- a/comfy_cli/schemas/build_push.json +++ b/comfy_cli/schemas/build_push.json @@ -12,7 +12,8 @@ "upload_count", "upload_bytes", "uploaded", - "deduped" + "deduped", + "public_pins_checked" ], "additionalProperties": false, "properties": { @@ -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" diff --git a/comfy_cli/skills/comfy-build/SKILL.md b/comfy_cli/skills/comfy-build/SKILL.md index 32f1878bb..169a6f04c 100644 --- a/comfy_cli/skills/comfy-build/SKILL.md +++ b/comfy_cli/skills/comfy-build/SKILL.md @@ -119,7 +119,8 @@ computes every upload locally and makes one read: it asks the builder to place each public pack, and refuses with `build_registry_pin_missing` exactly as `push` would, so a pin the push cannot save fails here, before you disclose the plan. A spec that pins a public pack therefore needs sign-in for the dry run; one whose -packs are all local sends nothing. Read what it plans, decide the pins, run the +packs are all local sends nothing. The `--json` payload's `public_pins_checked` +says how many public pins the builder placed (0: there were none to check). Read what it plans, decide the pins, run the conflict prediction in `comfy-build-pins`, disclose, get a yes. Only then: ```shell diff --git a/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md index 4f768876e..b771511e7 100644 --- a/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md +++ b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md @@ -60,6 +60,11 @@ for the pin check: identities, and refuse with the same `build_registry_pin_missing` code, message and hint. A spec the dry run passes on this check is one the push passes on this check, against the same builder state. +- **The payload says the check ran.** Push and dry run both put + `public_pins_checked` in the `--json` payload: how many public pins the + builder placed, and 0 when the spec has none and the builder was not asked. + A script or agent reads it to tell a checked pin set from one with nothing + to check, which the exit code alone cannot say. - **Failure is terminal.** If the lookup itself fails (network, 5xx, refused credential, or a response body that times out or drops mid-read), the dry run exits through `_builder_call` with the same error a push would get. It diff --git a/tests/comfy_cli/command/test_build_push.py b/tests/comfy_cli/command/test_build_push.py index 307607779..d3b0c3930 100644 --- a/tests/comfy_cli/command/test_build_push.py +++ b/tests/comfy_cli/command/test_build_push.py @@ -77,6 +77,7 @@ def test_dry_run_is_signed_out_and_zero_http(workspace: Path, monkeypatch: pytes assert data["dry_run"] is True assert data["upload_count"] == 2 assert data["upload_bytes"] == len(b"MODEL") + node_size + assert data["public_pins_checked"] == 0 assert path.read_bytes() == before @@ -374,9 +375,30 @@ def test_a_dry_run_asks_the_builder_only_to_place_its_public_pins( assert [(node["id"], node["version"]) for node in sent] == [("registry-node", "1.0.0")] data = envelope(result)["data"] assert (data["dry_run"], data["upload_count"], data["uploaded"]) == (True, 2, 0) + assert data["public_pins_checked"] == 1 + jsonschema.Draft202012Validator(_schema("build_push.json")).validate(data) assert path.read_bytes() == before +def test_a_real_push_reports_how_many_public_pins_the_builder_placed( + workspace: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + """A dry run and a push carry the same count, so a script reading either can + tell a checked pin set from a spec that had none to check.""" + # Given + write_spec(workspace, models=[], nodes=[local_node(), _REGISTRY_PIN]) + _install_client(monkeypatch, RecordingBuilder()) + + # When + result = invoke_push(workspace) + + # Then + assert result.exit_code == 0, result.stderr + data = envelope(result)["data"] + assert (data["dry_run"], data["public_pins_checked"]) == (False, 1) + jsonschema.Draft202012Validator(_schema("build_push.json")).validate(data) + + def test_a_dry_run_whose_pin_lookup_fails_exits_rather_than_passing( workspace: Path, monkeypatch: pytest.MonkeyPatch ) -> None: From 898bc77c7ea13796f868224072eac425336ba866 Mon Sep 17 00:00:00 2001 From: Vinh Trinh Date: Wed, 4 Nov 2026 23:15:50 -0500 Subject: [PATCH 6/6] fix(build): refuse a bad repository address before a dry run asks for sign-in --- comfy_cli/command/build.py | 34 ++++++++++++------- ...-run-check-public-pins-with-the-builder.md | 9 ++++- tests/comfy_cli/command/test_build_push.py | 21 ++++++++++++ 3 files changed, 50 insertions(+), 14 deletions(-) diff --git a/comfy_cli/command/build.py b/comfy_cli/command/build.py index a3d9630f9..16421a736 100644 --- a/comfy_cli/command/build.py +++ b/comfy_cli/command/build.py @@ -1894,19 +1894,10 @@ def _repository_is_sendable(repository: str) -> bool: return _canonical_github_repository(repository) is not None -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.""" +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 @@ -1923,6 +1914,22 @@ def _require_public_pins(renderer, client, public_nodes: list[dict], spec_file: 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})), @@ -2104,6 +2111,7 @@ def push_cmd( # 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 diff --git a/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md index b771511e7..4ccf2bd1a 100644 --- a/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md +++ b/docs/adr/BUILD-VALIDATION-0008-let-a-dry-run-check-public-pins-with-the-builder.md @@ -6,6 +6,11 @@ Date: 2026-11-04 Proposed +Relation: Builds on [ADR-AUTOMATION-0003](AUTOMATION-0003-one-versioned-machine-output-dialect.md). +One envelope per command and append-only error codes stay as they are. This ADR +adds no error code; it lets a dry run return `build_registry_pin_missing` with +its existing meaning. + ## Context `comfy build push --dry-run` used to send no HTTP at all. It computed the @@ -54,7 +59,9 @@ for the pin check: - **Sign-in.** The request goes through the same authenticated builder client as a push (`_builder_client`): an injected token, a Cloud token or API key from the environment, or the stored sign-in. With none of these, a dry run - with public pins fails with `build_not_signed_in`. + with public pins fails with `build_not_signed_in`. The repository address + check reads only the spec and runs before sign-in is asked for, so a bad + address gets `build_spec_invalid` signed in or out. - **Parity with push.** Push and dry run share one function, `_require_public_pins`. They send the same payload, compare the same identities, and refuse with the same `build_registry_pin_missing` code, diff --git a/tests/comfy_cli/command/test_build_push.py b/tests/comfy_cli/command/test_build_push.py index d3b0c3930..3de3c72b3 100644 --- a/tests/comfy_cli/command/test_build_push.py +++ b/tests/comfy_cli/command/test_build_push.py @@ -517,6 +517,27 @@ def test_a_repository_url_with_credentials_is_refused_before_any_request( assert "ghp_TOKENSECRET" not in result.output +def test_a_signed_out_dry_run_refuses_a_credentialed_repository_before_asking_for_sign_in( + workspace: Path, monkeypatch: pytest.MonkeyPatch +) -> None: + """The address check reads only the spec, so a signed-out dry run gets + ``build_spec_invalid`` for it, as a signed-in one does, not ``build_not_signed_in``.""" + # Given + node = {"name": "private-node", "source": "git", "repository": "https://ghp_TOKENSECRET@github.com/org/repo"} + write_spec(workspace, models=[], nodes=[{**node, "gitRef": "main"}]) + monkeypatch.setattr(build, "_builder_client", lambda *args, **kwargs: pytest.fail("constructed Builder client")) + + # When + result = invoke_push(workspace, "--dry-run") + + # Then + assert result.exit_code == 1 + error = envelope(result)["error"] + assert error["code"] == "build_spec_invalid" + assert "private-node" in error["message"] + assert "ghp_TOKENSECRET" not in result.output + + @pytest.mark.parametrize( "repository", [