fix: recognize OPENAI_API_KEY as valid auth for OpenAI-compatible endpoints

Adds OPENAI_API_KEY detection to check_auth_health() alongside existing api_key and auth_token checks, creating a combined any_auth_present variable. Also displays openai_key presence in the environment details.
This commit is contained in:
Emre Kerem Celenli 2026-05-25 04:21:14 +02:00 committed by GitHub
parent a61d023583
commit f72681f998
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2186,25 +2186,26 @@ fn check_auth_health() -> DiagnosticCheck {
let auth_token_present = env::var("ANTHROPIC_AUTH_TOKEN") let auth_token_present = env::var("ANTHROPIC_AUTH_TOKEN")
.ok() .ok()
.is_some_and(|value| !value.trim().is_empty()); .is_some_and(|value| !value.trim().is_empty());
let openai_key_present = env::var("OPENAI_API_KEY")
.ok()
.is_some_and(|value| !value.trim().is_empty());
let any_auth_present = api_key_present || auth_token_present || openai_key_present;
let env_details = format!( let env_details = format!(
"Environment api_key={} auth_token={}", "Environment api_key={} auth_token={} openai_key={}",
if api_key_present { "present" } else { "absent" }, if api_key_present { "present" } else { "absent" },
if auth_token_present { if auth_token_present { "present" } else { "absent" },
"present" if openai_key_present { "present" } else { "absent" }
} else {
"absent"
}
); );
match load_oauth_credentials() { match load_oauth_credentials() {
Ok(Some(token_set)) => DiagnosticCheck::new( Ok(Some(token_set)) => DiagnosticCheck::new(
"Auth", "Auth",
if api_key_present || auth_token_present { if any_auth_present {
DiagnosticLevel::Ok DiagnosticLevel::Ok
} else { } else {
DiagnosticLevel::Warn DiagnosticLevel::Warn
}, },
if api_key_present || auth_token_present { if any_auth_present {
"supported auth env vars are configured; legacy saved OAuth is ignored" "supported auth env vars are configured; legacy saved OAuth is ignored"
} else { } else {
"legacy saved OAuth credentials are present but unsupported" "legacy saved OAuth credentials are present but unsupported"
@ -2247,12 +2248,12 @@ fn check_auth_health() -> DiagnosticCheck {
])), ])),
Ok(None) => DiagnosticCheck::new( Ok(None) => DiagnosticCheck::new(
"Auth", "Auth",
if api_key_present || auth_token_present { if any_auth_present {
DiagnosticLevel::Ok DiagnosticLevel::Ok
} else { } else {
DiagnosticLevel::Warn DiagnosticLevel::Warn
}, },
if api_key_present || auth_token_present { if any_auth_present {
"supported auth env vars are configured" "supported auth env vars are configured"
} else { } else {
"no supported auth env vars were found" "no supported auth env vars were found"