apollographql / rover

The CLI for Apollo GraphOS
https://rover.apollo.dev
Other
405 stars 85 forks source link

Unintuitive behavior APOLLO_KEY supersedes --profile. #2074

Open drts01 opened 1 month ago

drts01 commented 1 month ago

Description

Unintuitive behavior, where environment variables supersede the CLI flags. Specifically, APOLLO_KEY supersedes --profile.

Steps to reproduce

  1. Create a profile with rover.
  2. Set an API key, APOLLO_KEY.
  3. Check auth with rover config whoami --profile PROFILE

Expected result

The profile flag should be used, not the environment variable APOLLO_KEY.

Actual result

❯ rover --skip-update-check config whoami --profile PROFILE --format json --log debug | jq .
  DEBUG rover::utils::env: $APOLLO_KEY = serv**************************************************fpGQ
    at src/utils/env.rs:36
...
  DEBUG houston::profile: using API key serv**************************************************fpGQ
    at crates/houston/src/profile/mod.rs:88

Checking identity of your API key against the registry.
  DEBUG rover_client::blocking::studio_client: self.version: "0.26.0"
    at crates/rover-client/src/blocking/studio_client.rs:87
...
  DEBUG houston::profile: using API key serv**************************************************fpGQ
    at crates/houston/src/profile/mod.rs:88

{
  "data": {
    "api_key": "serv**************************************************fpGQ",
    "graph_id": "Supergraph",
    "graph_title": "Supergraph",
    "key_type": "Graph",
    "origin": "$APOLLO_KEY",
    "success": true,
    "user_id": null
  },
  "error": null,
  "json_version": "1"
}

Environment

❯ rover info
Rover Info:
Version: 0.26.0
Install Location: /Users/<REDACTED>/.local/bin/rover
OS: Mac OS 14.6.1 [64-bit]
Shell: /bin/zsh
LongLiveCHIEF commented 6 days ago

related proposal https://github.com/apollographql/rover/issues/2047