mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-05-07 00:50:52 +00:00
fix: validate env-var tokens and align cloud_authenticate patterns (#1516)
- ensure_api_token_with_provider now validates env-var tokens with the provider test function, matching config-file token behavior. Previously, stale env-var tokens silently passed auth and failed at server creation with cryptic API errors. - Add prompt_spawn_name to Hetzner and Daytona cloud_authenticate, matching the pattern used by AWS, Fly, GCP, DigitalOcean, and Sprite. Without this, SPAWN_NAME_KEBAB is never set and server name prompts have no pre-filled default on these two providers. - Remove redundant register_cleanup_trap from DigitalOcean cloud_authenticate. shared/common.sh auto-registers the trap at source time (line 3696), making the explicit call dead code. Agent: code-health Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9de4cecfea
commit
32db000ca4
4 changed files with 9 additions and 5 deletions
|
|
@ -266,7 +266,7 @@ except Exception as e:
|
|||
# Cloud adapter interface
|
||||
# ============================================================
|
||||
|
||||
cloud_authenticate() { ensure_daytona_token; }
|
||||
cloud_authenticate() { prompt_spawn_name; ensure_daytona_token; }
|
||||
cloud_provision() { create_server "$1"; }
|
||||
cloud_wait_ready() { wait_for_cloud_init; }
|
||||
cloud_run() { run_server "$1"; }
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ for d in droplets:
|
|||
# Cloud adapter interface
|
||||
# ============================================================
|
||||
|
||||
cloud_authenticate() { prompt_spawn_name; register_cleanup_trap; ensure_do_token; ensure_ssh_key; }
|
||||
cloud_authenticate() { prompt_spawn_name; ensure_do_token; ensure_ssh_key; }
|
||||
cloud_provision() { create_server "$1"; }
|
||||
cloud_wait_ready() { verify_server_connectivity "${DO_SERVER_IP}"; wait_for_cloud_init "${DO_SERVER_IP}" 60; }
|
||||
cloud_run() { run_server "${DO_SERVER_IP}" "$1"; }
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ list_servers() {
|
|||
# Cloud adapter interface
|
||||
# ============================================================
|
||||
|
||||
cloud_authenticate() { ensure_hcloud_token; ensure_ssh_key; }
|
||||
cloud_authenticate() { prompt_spawn_name; ensure_hcloud_token; ensure_ssh_key; }
|
||||
cloud_provision() { create_server "$1"; }
|
||||
cloud_wait_ready() { verify_server_connectivity "${HETZNER_SERVER_IP}"; wait_for_cloud_init "${HETZNER_SERVER_IP}" 60; }
|
||||
cloud_run() { run_server "${HETZNER_SERVER_IP}" "$1"; }
|
||||
|
|
|
|||
|
|
@ -2802,9 +2802,13 @@ ensure_api_token_with_provider() {
|
|||
|
||||
check_python_available || return 1
|
||||
|
||||
# Try environment variable
|
||||
# Try environment variable (validate if test function provided)
|
||||
if _load_token_from_env "${env_var_name}" "${provider_name}"; then
|
||||
return 0
|
||||
if [[ -z "${test_func}" ]] || "${test_func}" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
log_warn "${provider_name} token from environment is invalid or expired"
|
||||
unset "${env_var_name}"
|
||||
fi
|
||||
|
||||
# Try config file (validate if test function provided, fall through to prompt on failure)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue