feat(arcade-cli): remember login host for subsequent commands
Summary
arcade login -h cloud.X.dev now persists the matching Engine URL so every subsequent CLI command (engine-side and coordinator-side) targets that environment by default. Today, users who log into a non-prod host have to repeat -h on every command, and confusingly some commands expect the Coordinator host (cloud.X.dev) while others expect the Engine host (api.X.dev).
Resolution order is now: explicit flags > saved URL > production default.
Resolves:
Design decisions
- Stored both URLs explicitly.
coordinator_urlwas already persisted but never used as a default; this PR addsengine_urlnext to it. Storing both is simpler and clearer than recomputing the engine URL on every command. - Convention-based derivation.
derive_engine_url_from_coordinatorswaps thecloud.prefix forapi.and preserves the port; localhost getslocalhost:9099. Unknown hostnames returnNoneso the caller falls back to prod, matching today's behavior. This avoids inventing a parallel--engine-hostflag at login time for the 99% case while leaving a clean follow-up if a non-conventional env ever needs it. - One resolution helper per concern (
resolve_engine_url,resolve_coordinator_url) instead of magic inside each callback. Each typer.Option-hdefault flips fromPROD_*_HOSTtoNone, and the callback body becomes a one-liner. - Backward compatible. Pre-existing
credentials.yamlfiles don't haveengine_urlset; commands fall back toapi.arcade.devexactly as before. Logged-out users see no behavior change. whoamisurfaces both URLs, with non-prod URLs highlighted in yellow so a glance confirms which environment is active. Login banner shows them too.
Scope
In scope:
- Persistence layer (Config schema, save_credentials_from_whoami)
- Login derives and persists the engine URL
- Every CLI command with a
-hflag resolves through the saved URL whoamisurfaces both URLs
Not in scope (handled separately):
- Profile / environment switching (
arcade env use staging) — bigger feature that can build on top of this - Explicit
--engine-hostflag onarcade loginfor non-conventional hosts — small follow-up if a real env stops following thecloud.X/api.Xconvention
Test plan
- [x]
make check(ruff + mypy) clean - [x]
make test— 3605 passed, 1 skipped (evals) - [x] 33 new unit tests covering derivation, persistence, resolution, every callback's URL choice, and
whoamioutput - [x] End-to-end smoke test: saved a real
credentials.yamlwith non-prod URLs to a tmpARCADE_WORK_DIR, confirmedresolve_engine_url/resolve_coordinator_urlreturn the saved URLs, and that explicit flags still override - [x] Verified the no-credentials path still returns the production defaults (regression check for logged-out users)
- [ ] Reviewer to dry-run
arcade login -h <non-prod-coordinator>thenarcade server list/arcade secret list/arcade org listwith no-hand confirm each hits the right host
Risk note
Touches the CLI surface every internal user relies on. Blast radius:
- Logged-out users: every command falls back to the prod default exactly as before. Covered by
test_*_no_creds_falls_back_to_prodtests. - Logged-in users with pre-existing credentials.yaml:
engine_urlisNoneuntil they re-log in, so commands fall back to prod. Same behavior as today. No migration required. - Logged-in users on a non-prod env: after their next
arcade login, commands stop needing-h. If derivation fails for some reason,engine_urlstaysNoneand they get the same behavior as today. - Explicit
-h/-p/--tls/--no-tlsalways wins, so the escape hatch is preserved.
Author checklist
- [ ] I understand every change in the diff
- [x]
make checkandmake testgreen locally; CI is expected to pass - [ ] Pulled the branch fresh and reviewed my own diff top-to-bottom
- [ ] I'd merge it myself if a teammate said LGTM right now
[!NOTE] Medium Risk Touches host/URL selection logic across many CLI commands and changes default targeting behavior after login, so regressions could misroute requests to the wrong environment. Risk is mitigated by centralized resolution helpers plus extensive new unit tests and safe fallbacks to prod when credentials are missing or unreadable.
Overview After
arcade login, the CLI now persists both Coordinator and Engine base URLs (newConfig.engine_url) so subsequent commands default to the same environment without repeatedly passing-h/--host.Adds centralized URL resolution (
resolve_engine_url,resolve_coordinator_url) that applies explicit flags > saved URL > prod defaults, including layering--port/--tls/--no-tlson top of the saved host when--hostisn’t provided, and falling back safely ifcredentials.yamlis missing/corrupted.Updates engine- and coordinator-backed commands (e.g.,
server,secret,org,project,show,deploy,dashboard) to use the new resolvers and makes--hostoptional, whileloginderives and saves the matching engine URL andwhoaminow prints both URLs (highlighting non-prod). Extensive new tests cover persistence, derivation, resolution precedence, and callbacks using saved defaults.Reviewed by Cursor Bugbot for commit 0aa63d3fdb5a101bdf7d9cc4808eae4f02e2931e. Bugbot is set up for automated code reviews on this repo. Configure here.
Codecov Report
:x: Patch coverage is 85.33333% with 11 lines in your changes missing coverage. Please review.
| Files with missing lines | Coverage Δ | |
|---|---|---|
| libs/arcade-cli/arcade_cli/authn.py | 77.38% <ø> (+12.20%) |
:arrow_up: |
| libs/arcade-cli/arcade_cli/org.py | 36.36% <100.00%> (+15.46%) |
:arrow_up: |
| libs/arcade-cli/arcade_cli/project.py | 38.46% <100.00%> (+17.24%) |
:arrow_up: |
| libs/arcade-cli/arcade_cli/secret.py | 68.85% <100.00%> (+2.18%) |
:arrow_up: |
| libs/arcade-cli/arcade_cli/server.py | 33.88% <100.00%> (+1.47%) |
:arrow_up: |
| libs/arcade-cli/arcade_cli/show.py | 60.00% <ø> (ø) |
|
| libs/arcade-core/arcade_core/config_model.py | 77.19% <100.00%> (+3.08%) |
:arrow_up: |
| libs/arcade-cli/arcade_cli/deploy.py | 47.01% <0.00%> (ø) |
|
| libs/arcade-cli/arcade_cli/main.py | 38.51% <58.33%> (+6.06%) |
:arrow_up: |
| libs/arcade-cli/arcade_cli/utils.py | 60.77% <89.79%> (+3.71%) |
:arrow_up: |
... and 1 file with indirect coverage changes
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
This pull request has been automatically marked as stale because it has had no activity for 14 days. It will be closed in 14 days if no further activity occurs. If this is still relevant, please leave a comment or remove the stale label.
This pull request has been automatically marked as stale because it has had no activity for 14 days. It will be closed in 14 days if no further activity occurs. If this is still relevant, please leave a comment or remove the stale label.
This pull request has been closed due to inactivity. Feel free to reopen it if it is still relevant.