Skip to content

fix(cli): honor saved coordinator host - #898

Open
adity982 wants to merge 4 commits into
ArcadeAI:mainfrom
adity982:agent/use-saved-coordinator-host
Open

fix(cli): honor saved coordinator host#898
adity982 wants to merge 4 commits into
ArcadeAI:mainfrom
adity982:agent/use-saved-coordinator-host

Conversation

@adity982

@adity982 adity982 commented Jul 22, 2026

Copy link
Copy Markdown

Summary

Organization and project commands now use the coordinator URL saved by arcade login when no connection flags are provided, matching the behavior of the rest of the CLI. Explicit host, port, and TLS flags continue to take precedence.

Resolves: #896

Design decisions

The fallback is centralized in resolve_coordinator_url so both command groups share the same precedence rules. The visible --host default remains the production coordinator for help output, while None internally distinguishes an omitted flag from an explicit override.

Test plan

  • uv run pytest libs/tests/cli/test_org_project.py (3 passed)
  • uv run ruff check for the changed Python files
  • uv run ruff format --check for the changed Python files

Author checklist

Before moving this PR from Draft to Ready for Review:

  • Linked to a GitHub issue (above)
  • I understand every change in the diff
  • Runs locally, exercised through the end-user path (not just unit tests)
  • make check and make test are green locally; CI is expected to pass
  • I've reviewed my own diff top-to-bottom
  • I'd merge it myself if a teammate said LGTM right now

Note

Low Risk
Localized CLI connection resolution with clear precedence rules and unit tests; no auth or server-side behavior changes.

Overview
arcade org and arcade project now use the coordinator URL from login config when you don't pass --host, --port, or TLS flags—instead of always targeting production.

A shared resolve_coordinator_url helper implements precedence: saved coordinator_url from config when all connection options are omitted; otherwise compute_base_url with explicit flags (e.g. --host still overrides the saved URL). --host defaults to None internally so "not passed" is distinguishable from an override, while help still shows the production host via show_default.

CLI tests cover saved URL usage, explicit host override, and production fallback when config is missing.

Reviewed by Cursor Bugbot for commit b04ae23. Bugbot is set up for automated code reviews on this repo. Configure here.

@EricGustin
EricGustin marked this pull request as ready for review July 26, 2026 19:43

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 5daa4a2. Configure here.

Comment thread libs/arcade-cli/arcade_cli/utils.py Outdated
@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
libs/arcade-cli/arcade_cli/org.py 34.84% <100.00%> (+13.95%) ⬆️
libs/arcade-cli/arcade_cli/project.py 38.46% <100.00%> (+17.24%) ⬆️
libs/arcade-cli/arcade_cli/utils.py 57.98% <100.00%> (+0.93%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

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.

@github-actions github-actions Bot added the stale label Aug 10, 2026
@adity982

Copy link
Copy Markdown
Author

Addressed the missing-config review finding in commit 3aab68d and merged current upstream main.
esolve_coordinator_url now falls back to the production coordinator when no saved config exists, with a CLI regression covering the no-config path. Post-merge validation: 4 focused tests passed; Ruff lint/format and lockfile checks passed. The review thread is now automatically resolved/outdated on the new head.

@github-actions github-actions Bot removed the stale label Aug 11, 2026
@EricGustin

Copy link
Copy Markdown
Member

@greptileai

@greptile-apps

greptile-apps Bot commented Aug 13, 2026

Copy link
Copy Markdown

Greptile Summary

Organization and project commands now resolve their coordinator URL from saved login configuration when no connection flags are supplied, while retaining explicit-option and production fallbacks.

  • Adds a shared coordinator URL resolver.
  • Updates both command callbacks to distinguish omitted hosts from explicit overrides.
  • Adds tests for saved URLs, host overrides, and missing configuration.

Confidence Score: 4/5

The PR appears safe to merge after addressing the non-blocking configuration-error handling and required package version update.

The intended saved-host precedence is implemented consistently, but invalid existing configuration can now escape from callbacks as a traceback, and the repository-required library version increment is absent.

Files Needing Attention: libs/arcade-cli/arcade_cli/utils.py and pyproject.toml

Important Files Changed

Filename Overview
libs/arcade-cli/arcade_cli/utils.py Adds centralized saved-URL resolution, but non-missing configuration errors can escape from command callbacks.
libs/arcade-cli/arcade_cli/org.py Changes the organization callback to distinguish an omitted host and delegate coordinator resolution.
libs/arcade-cli/arcade_cli/project.py Applies the same coordinator-resolution behavior to project commands.
libs/tests/cli/test_org_project.py Covers saved coordinator URLs, explicit host precedence, and production fallback, but not invalid configuration files.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Organization or project callback] --> B{Any connection flag supplied?}
    B -- Yes --> C[Build URL from explicit options and production host fallback]
    B -- No --> D[Load saved configuration]
    D --> E{Saved coordinator URL exists?}
    E -- Yes --> F[Use saved coordinator URL]
    E -- No or file missing --> G[Use production coordinator URL]
Loading

Reviews (1): Last reviewed commit: "Merge branch 'main' into agent/use-saved..." | Re-trigger Greptile

Comment on lines +590 to +595
saved_url = Config.load_from_file().coordinator_url
if saved_url:
return saved_url
except FileNotFoundError:
pass

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Handle invalid saved configuration

If the saved credentials file is malformed, structurally invalid, or unreadable, Config.load_from_file() raises an exception other than FileNotFoundError; because this now runs in the application callback, organization and project commands terminate with a traceback before their existing user-facing configuration handling runs.

Comment on lines +579 to +604
def resolve_coordinator_url(
host: str | None,
port: int | None,
force_tls: bool,
force_no_tls: bool,
) -> str:
"""Resolve coordinator CLI options, falling back to the saved login host."""
if host is None and port is None and not force_tls and not force_no_tls:
from arcade_core.config_model import Config

try:
saved_url = Config.load_from_file().coordinator_url
if saved_url:
return saved_url
except FileNotFoundError:
pass

from arcade_core.constants import PROD_COORDINATOR_HOST

return compute_base_url(
force_tls,
force_no_tls,
host or PROD_COORDINATOR_HOST,
port,
default_port=None,
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Version the CLI behavior change

This adds new arcade-cli behavior without increasing the version in pyproject.toml, so package consumers and release automation cannot distinguish the changed coordinator resolution behavior from the existing release.

Context Used: Guidelines for library versioning (source)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

force_no_tls: bool,
) -> str:
"""Resolve coordinator CLI options, falling back to the saved login host."""
if host is None and port is None and not force_tls and not force_no_tls:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Gate on if host is None.

Assume the saved coodinator_url is https://coordinator.tenant.example.com

Then,

Command Resolves to
arcade org list https://coordinator.tenant.example.com correct
arcade org --host other.com list https://other.com correct
arcade org --port 8443 list https://cloud.arcade.dev:8443 wrong host
arcade org --tls list https://cloud.arcade.dev wrong host
arcade org --no-tls list http://cloud.arcade.dev wrong host

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] CLI: org/project commands ignore saved coordinator host and default to Arcade Cloud

2 participants