mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
Remove OPENAI_BASE_URL config fallback (#16720)
The `OPENAI_BASE_URL` environment variable has been a significant support issue, so we decided to deprecate it in favor of an `openai_base_url` config key. We've had the deprecation warning in place for about a month, so users have had time to migrate to the new mechanism. This PR removes support for `OPENAI_BASE_URL` entirely.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
const OPENAI_BASE_URL_ENV_VAR: &str = "OPENAI_BASE_URL";
|
||||
pub const FEEDBACK_DIAGNOSTICS_ATTACHMENT_FILENAME: &str = "codex-connectivity-diagnostics.txt";
|
||||
const PROXY_ENV_VARS: &[&str] = &[
|
||||
"HTTP_PROXY",
|
||||
@@ -58,13 +57,6 @@ impl FeedbackDiagnostics {
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(value) = env.get(OPENAI_BASE_URL_ENV_VAR).map(String::as_str) {
|
||||
diagnostics.push(FeedbackDiagnostic {
|
||||
headline: "OPENAI_BASE_URL is set and may affect connectivity.".to_string(),
|
||||
details: vec![format!("{OPENAI_BASE_URL_ENV_VAR} = {value}")],
|
||||
});
|
||||
}
|
||||
|
||||
Self { diagnostics }
|
||||
}
|
||||
|
||||
@@ -112,38 +104,34 @@ mod tests {
|
||||
),
|
||||
("http_proxy", "proxy.example.com:8080"),
|
||||
("all_proxy", "socks5h://all-proxy.example.com:1080"),
|
||||
("OPENAI_BASE_URL", "https://example.com/v1?token=secret"),
|
||||
]);
|
||||
|
||||
assert_eq!(
|
||||
diagnostics,
|
||||
FeedbackDiagnostics {
|
||||
diagnostics: vec![
|
||||
FeedbackDiagnostic {
|
||||
headline:
|
||||
"Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec![
|
||||
"http_proxy = proxy.example.com:8080".to_string(),
|
||||
"HTTPS_PROXY = https://user:password@secure-proxy.example.com:443?secret=1".to_string(),
|
||||
"all_proxy = socks5h://all-proxy.example.com:1080".to_string(),
|
||||
],
|
||||
},
|
||||
FeedbackDiagnostic {
|
||||
headline: "OPENAI_BASE_URL is set and may affect connectivity.".to_string(),
|
||||
details: vec![
|
||||
"OPENAI_BASE_URL = https://example.com/v1?token=secret".to_string(),
|
||||
],
|
||||
},
|
||||
],
|
||||
diagnostics: vec![FeedbackDiagnostic {
|
||||
headline: "Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec![
|
||||
"http_proxy = proxy.example.com:8080".to_string(),
|
||||
"HTTPS_PROXY = https://user:password@secure-proxy.example.com:443?secret=1"
|
||||
.to_string(),
|
||||
"all_proxy = socks5h://all-proxy.example.com:1080".to_string(),
|
||||
],
|
||||
},],
|
||||
}
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
diagnostics.attachment_text(),
|
||||
Some(
|
||||
"Connectivity diagnostics\n\n- Proxy environment variables are set and may affect connectivity.\n - http_proxy = proxy.example.com:8080\n - HTTPS_PROXY = https://user:password@secure-proxy.example.com:443?secret=1\n - all_proxy = socks5h://all-proxy.example.com:1080\n- OPENAI_BASE_URL is set and may affect connectivity.\n - OPENAI_BASE_URL = https://example.com/v1?token=secret"
|
||||
.to_string()
|
||||
r#"Connectivity diagnostics
|
||||
|
||||
- Proxy environment variables are set and may affect connectivity.
|
||||
- http_proxy = proxy.example.com:8080
|
||||
- HTTPS_PROXY = https://user:password@secure-proxy.example.com:443?secret=1
|
||||
- all_proxy = socks5h://all-proxy.example.com:1080"#
|
||||
.to_string()
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -156,45 +144,18 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collect_from_pairs_preserves_openai_base_url_literal_value() {
|
||||
let diagnostics = FeedbackDiagnostics::collect_from_pairs([(
|
||||
"OPENAI_BASE_URL",
|
||||
"https://api.openai.com/v1/",
|
||||
)]);
|
||||
fn collect_from_pairs_preserves_whitespace_and_empty_values() {
|
||||
let diagnostics =
|
||||
FeedbackDiagnostics::collect_from_pairs([("HTTP_PROXY", " proxy with spaces ")]);
|
||||
|
||||
assert_eq!(
|
||||
diagnostics,
|
||||
FeedbackDiagnostics {
|
||||
diagnostics: vec![FeedbackDiagnostic {
|
||||
headline: "OPENAI_BASE_URL is set and may affect connectivity.".to_string(),
|
||||
details: vec!["OPENAI_BASE_URL = https://api.openai.com/v1/".to_string()],
|
||||
}],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn collect_from_pairs_preserves_whitespace_and_empty_values() {
|
||||
let diagnostics = FeedbackDiagnostics::collect_from_pairs([
|
||||
("HTTP_PROXY", " proxy with spaces "),
|
||||
("OPENAI_BASE_URL", ""),
|
||||
]);
|
||||
|
||||
assert_eq!(
|
||||
diagnostics,
|
||||
FeedbackDiagnostics {
|
||||
diagnostics: vec![
|
||||
FeedbackDiagnostic {
|
||||
headline:
|
||||
"Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec!["HTTP_PROXY = proxy with spaces ".to_string()],
|
||||
},
|
||||
FeedbackDiagnostic {
|
||||
headline: "OPENAI_BASE_URL is set and may affect connectivity.".to_string(),
|
||||
details: vec!["OPENAI_BASE_URL = ".to_string()],
|
||||
},
|
||||
],
|
||||
headline: "Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec!["HTTP_PROXY = proxy with spaces ".to_string()],
|
||||
},],
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -202,27 +163,16 @@ mod tests {
|
||||
#[test]
|
||||
fn collect_from_pairs_reports_values_verbatim() {
|
||||
let proxy_value = "not a valid proxy";
|
||||
let base_url_value = "hello";
|
||||
let diagnostics = FeedbackDiagnostics::collect_from_pairs([
|
||||
("HTTP_PROXY", proxy_value),
|
||||
("OPENAI_BASE_URL", base_url_value),
|
||||
]);
|
||||
let diagnostics = FeedbackDiagnostics::collect_from_pairs([("HTTP_PROXY", proxy_value)]);
|
||||
|
||||
assert_eq!(
|
||||
diagnostics,
|
||||
FeedbackDiagnostics {
|
||||
diagnostics: vec![
|
||||
FeedbackDiagnostic {
|
||||
headline:
|
||||
"Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec!["HTTP_PROXY = not a valid proxy".to_string()],
|
||||
},
|
||||
FeedbackDiagnostic {
|
||||
headline: "OPENAI_BASE_URL is set and may affect connectivity.".to_string(),
|
||||
details: vec!["OPENAI_BASE_URL = hello".to_string()],
|
||||
},
|
||||
],
|
||||
diagnostics: vec![FeedbackDiagnostic {
|
||||
headline: "Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec!["HTTP_PROXY = not a valid proxy".to_string()],
|
||||
},],
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -650,8 +650,9 @@ mod tests {
|
||||
let snapshot_with_diagnostics = CodexFeedback::new()
|
||||
.snapshot(/*session_id*/ None)
|
||||
.with_feedback_diagnostics(FeedbackDiagnostics::new(vec![FeedbackDiagnostic {
|
||||
headline: "OPENAI_BASE_URL is set and may affect connectivity.".to_string(),
|
||||
details: vec!["OPENAI_BASE_URL = https://example.com/v1".to_string()],
|
||||
headline: "Proxy environment variables are set and may affect connectivity."
|
||||
.to_string(),
|
||||
details: vec!["HTTPS_PROXY = https://example.com:443".to_string()],
|
||||
}]));
|
||||
|
||||
let attachments_with_diagnostics = snapshot_with_diagnostics.feedback_attachments(
|
||||
@@ -674,7 +675,7 @@ mod tests {
|
||||
assert_eq!(attachments_with_diagnostics[0].buffer, vec![1]);
|
||||
assert_eq!(
|
||||
attachments_with_diagnostics[1].buffer,
|
||||
b"Connectivity diagnostics\n\n- OPENAI_BASE_URL is set and may affect connectivity.\n - OPENAI_BASE_URL = https://example.com/v1".to_vec()
|
||||
b"Connectivity diagnostics\n\n- Proxy environment variables are set and may affect connectivity.\n - HTTPS_PROXY = https://example.com:443".to_vec()
|
||||
);
|
||||
assert_eq!(attachments_with_diagnostics[2].buffer, b"rollout".to_vec());
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user