From fdf2d9cab77e66a16f34cdc93625d900ce7c65de Mon Sep 17 00:00:00 2001 From: jdicorpo Date: Tue, 21 Apr 2026 07:00:22 -0700 Subject: [PATCH] fix(keygen): call /auth/cli/ssh-key instead of /users/me (2.4.5) `cf keygen` was trying to auto-register the generated SSH public key via `PUT /users/me`, but that route is only wired on the internal backend. Hitting api.chipfoundry.io produced an `HTTP 404: Not Found` that looked like a CLI bug and leaked through `_api_put`'s error printer before the friendly "To register this key" fallback, confusing users. Switch `_try_register_ssh_key` to the new CLI-native endpoint `PUT /api/v1/auth/cli/ssh-key` on the public API (see backend PR), and swallow transport errors silently so the manual-registration instructions are the only thing the user sees when auto-registration is unavailable (e.g. not logged in, older backend, offline). Made-with: Cursor --- chipfoundry_cli/main.py | 23 ++++++++++++++++++++--- pyproject.toml | 2 +- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/chipfoundry_cli/main.py b/chipfoundry_cli/main.py index d410c8c..f22cad2 100644 --- a/chipfoundry_cli/main.py +++ b/chipfoundry_cli/main.py @@ -205,16 +205,33 @@ def config_cmd(): def _try_register_ssh_key(public_key: str) -> bool: """Attempt to register the SSH public key on the user's platform profile. - Returns True if the key was registered successfully, False otherwise. + Calls the CLI-specific ``PUT /auth/cli/ssh-key`` endpoint so the request + stays on the public API surface. Returns True on success, False otherwise. + Errors are swallowed silently so the caller can print the manual-registration + fallback without a scary ``API request failed`` line first. """ + import httpx as _httpx + config = load_user_config() if not config.get("api_key"): return False + try: - _api_put("/users/me", {"ssh_public_key": public_key}) - return True + client, _ = _api_client() except SystemExit: return False + try: + resp = client.put("/auth/cli/ssh-key", json={"ssh_public_key": public_key}) + if resp.status_code == 200: + return True + return False + except _httpx.HTTPError: + return False + finally: + try: + client.close() + except Exception: + pass def _print_manual_key_instructions(): diff --git a/pyproject.toml b/pyproject.toml index d6b3556..2030311 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "chipfoundry-cli" -version = "2.4.4" +version = "2.4.5" description = "CLI tool to automate ChipFoundry project submission to SFTP server" authors = ["ChipFoundry "] readme = "README.md"