Skip to content

Commit 77244bd

Browse files
jeffdijdicorpo
andauthored
fix(keygen): call /auth/cli/ssh-key instead of /users/me (2.4.5) (#19)
`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 Co-authored-by: jdicorpo <jdicorpo@gmail.com>
1 parent e5e5a9b commit 77244bd

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

chipfoundry_cli/main.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,16 +205,33 @@ def config_cmd():
205205
def _try_register_ssh_key(public_key: str) -> bool:
206206
"""Attempt to register the SSH public key on the user's platform profile.
207207
208-
Returns True if the key was registered successfully, False otherwise.
208+
Calls the CLI-specific ``PUT /auth/cli/ssh-key`` endpoint so the request
209+
stays on the public API surface. Returns True on success, False otherwise.
210+
Errors are swallowed silently so the caller can print the manual-registration
211+
fallback without a scary ``API request failed`` line first.
209212
"""
213+
import httpx as _httpx
214+
210215
config = load_user_config()
211216
if not config.get("api_key"):
212217
return False
218+
213219
try:
214-
_api_put("/users/me", {"ssh_public_key": public_key})
215-
return True
220+
client, _ = _api_client()
216221
except SystemExit:
217222
return False
223+
try:
224+
resp = client.put("/auth/cli/ssh-key", json={"ssh_public_key": public_key})
225+
if resp.status_code == 200:
226+
return True
227+
return False
228+
except _httpx.HTTPError:
229+
return False
230+
finally:
231+
try:
232+
client.close()
233+
except Exception:
234+
pass
218235

219236

220237
def _print_manual_key_instructions():

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "chipfoundry-cli"
3-
version = "2.4.4"
3+
version = "2.4.5"
44
description = "CLI tool to automate ChipFoundry project submission to SFTP server"
55
authors = ["ChipFoundry <marwan.abbas@chipfoundry.io>"]
66
readme = "README.md"

0 commit comments

Comments
 (0)