Skip to content

fix: point users to --api-key when rp login fails - #678

Closed
marie-karpinska wants to merge 2 commits into
mainfrom
mariekarpinska/rp-login-escape-hint
Closed

marie-karpinska wants to merge 2 commits into
mainfrom
mariekarpinska/rp-login-escape-hint

Conversation

@marie-karpinska

Copy link
Copy Markdown
Contributor

When rp login fails, the error now gives the user two concrete next steps:

  1. where to grab a key from the console and how to pass it with rp login --api-key
  2. if a newer runpod version is already cached by the daily update check, a note suggesting pip install -U runpod may fix the problem

The upgrade note only appears when the local update cache has a newer version than the installed one, so it stays silent on the common case where the user is already up to date

Follow up to #675

How I tested

  • uv run pytest tests/test_cli/test_management_commands.py tests/test_cli/test_agent_login.py tests/test_apps/test_auth.py tests/test_apps/test_api_client.py passes (139 tests)

The failure branch of rp login now prints the console settings URL and the rp login --api-key command so a user who hits a login error sees a working alternative without looking it up.
when the daily update cache has a newer runpod cached, the login error appends a line pointing to pip install -U runpod. silent when there's no newer version.
@marie-karpinska

Copy link
Copy Markdown
Contributor Author

#675 already provides hint on error
"rp login needs an interactive terminal to paste the API key.
Set RUNPOD_API_KEY, run rp login --api-key YOUR_KEY, or add the
key to ~/.runpod/config.toml."

Comment thread runpod/rp_cli/main.py
f"{exc}\n\n"
"if rp login keeps failing, grab a key from "
"https://console.runpod.io/user/settings and run:\n"
" rp login --api-key YOUR_KEY"

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.

If the failing run was rp login --profile staging, following this hint as written stores the key under the default profile, so the next rp --profile staging ... still has no credentials. Could the hint include --profile {profile} when it isn't the default?

Comment thread runpod/rp_cli/update.py
# -- passive background check -------------------------------------------


def cached_newer_version() -> Optional[str]:

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.

The four branches here (no or stale cache, missing latest_version, same or older, newer) aren't covered, and they decide whether a failing login suggests an upgrade. A small parametrized test over a temp CACHE_PATH would pin them, including a pre-release like 2.0.0rc1 vs 2.0.0, which parse_version truncates to (2, 0) and so reads as not newer.

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.

2 participants