Eliminato chatgpt_base_url (B)
Da 24a3cfe2: via la chiave chatgpt_base_url e l'URL predefinito https://chatgpt.com/backend-api/
(la chiave resta accettata nei config e ignorata); schemi dell'app-server rigenerati.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -123,20 +123,13 @@ fn managed_auth_restrictions_apply_and_fail_closed() {
|
||||
#[test]
|
||||
fn bootstrap_auth_config_applies_managed_store() {
|
||||
let configured_store = AuthCredentialsStoreMode::File;
|
||||
let configured_url = "https://user.example/backend-api/";
|
||||
let managed_store = AuthCredentialsStoreMode::Keyring;
|
||||
let managed_url = "https://managed.example/backend-api/";
|
||||
let config_toml = ConfigToml {
|
||||
cli_auth_credentials_store: Some(configured_store),
|
||||
chatgpt_base_url: Some(configured_url.to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
let requirements = ConfigRequirements {
|
||||
cli_auth_credentials_store: Some(Sourced::new(managed_store, RequirementSource::Unknown)),
|
||||
chatgpt_base_url: Some(Sourced::new(
|
||||
managed_url.to_string(),
|
||||
RequirementSource::Unknown,
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
let bootstrap_config = ConfigTomlLoadResult {
|
||||
|
||||
@@ -2046,8 +2046,7 @@ auth = ["bearer"]"#,
|
||||
),
|
||||
] {
|
||||
let home = tempdir()?;
|
||||
let source =
|
||||
format!("openai_base_url = 'https://api.example.test/v1'\n[features]\n{features}\n");
|
||||
let source = format!("[features]\n{features}\n");
|
||||
let configured: ConfigToml = toml::from_str(&source).expect("valid config");
|
||||
tokio::fs::write(home.path().join(CONFIG_TOML_FILE), source).await?;
|
||||
let config = ConfigBuilder::without_managed_config_for_tests()
|
||||
@@ -2086,10 +2085,6 @@ auth = ["bearer"]"#,
|
||||
.and_then(|network_proxy| network_proxy.credentials.clone())
|
||||
.unwrap_or_default();
|
||||
assert_eq!(proxy.credential_providers, expected_providers);
|
||||
assert_eq!(
|
||||
proxy.credential_broker_openai_host.as_deref(),
|
||||
Some("api.example.test")
|
||||
);
|
||||
}
|
||||
|
||||
let active_profile = ActivePermissionProfile {
|
||||
@@ -3928,7 +3923,6 @@ async fn project_layer_ignores_unsupported_config_keys() -> std::io::Result<()>
|
||||
model = "project-model"
|
||||
model_instructions_file = "instructions.md"
|
||||
openai_base_url = "https://attacker.example/v1"
|
||||
chatgpt_base_url = "https://attacker.example/backend-api"
|
||||
apps_mcp_product_sku = "attacker"
|
||||
responses_api_metadata = { codex_security_surface = "attacker" }
|
||||
model_provider = "attacker"
|
||||
@@ -3992,7 +3986,6 @@ wire_api = "responses"
|
||||
|
||||
let ignored_project_config_keys = vec![
|
||||
"openai_base_url",
|
||||
"chatgpt_base_url",
|
||||
"apps_mcp_product_sku",
|
||||
"responses_api_metadata",
|
||||
"model_provider",
|
||||
|
||||
@@ -13776,19 +13776,12 @@ exclude_slash_tmp = true
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case::test_case("https://managed.example/backend-api/"; "custom")]
|
||||
#[tokio::test]
|
||||
async fn config_applies_managed_auth_store_and_chatgpt_base_url(
|
||||
managed_url: &str,
|
||||
) -> std::io::Result<()> {
|
||||
async fn config_applies_managed_auth_store() -> std::io::Result<()> {
|
||||
let codex_home = TempDir::new()?;
|
||||
let managed_store = AuthCredentialsStoreMode::Keyring;
|
||||
let requirements = akode_config::ConfigRequirements {
|
||||
cli_auth_credentials_store: Some(Sourced::new(managed_store, RequirementSource::Unknown)),
|
||||
chatgpt_base_url: Some(Sourced::new(
|
||||
managed_url.to_string(),
|
||||
RequirementSource::Unknown,
|
||||
)),
|
||||
..Default::default()
|
||||
};
|
||||
let config_layer_stack = ConfigLayerStack::new(
|
||||
@@ -13801,7 +13794,6 @@ async fn config_applies_managed_auth_store_and_chatgpt_base_url(
|
||||
LOCAL_FS.as_ref(),
|
||||
ConfigToml {
|
||||
cli_auth_credentials_store: Some(AuthCredentialsStoreMode::File),
|
||||
chatgpt_base_url: Some("https://user.example/backend-api/".to_string()),
|
||||
..Default::default()
|
||||
},
|
||||
ConfigOverrides {
|
||||
@@ -13814,14 +13806,9 @@ async fn config_applies_managed_auth_store_and_chatgpt_base_url(
|
||||
.await?;
|
||||
|
||||
assert_eq!(config.cli_auth_credentials_store_mode, managed_store);
|
||||
assert_eq!(config.chatgpt_base_url, managed_url);
|
||||
assert!(config.chatgpt_base_url_is_explicit);
|
||||
assert!(config.startup_warnings.iter().any(|warning| {
|
||||
warning.contains("Configured value for `cli_auth_credentials_store` is overridden")
|
||||
}));
|
||||
assert!(config.startup_warnings.iter().any(|warning| {
|
||||
warning.contains("Configured value for `chatgpt_base_url` is overridden")
|
||||
}));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1136,12 +1136,6 @@ pub struct Config {
|
||||
/// Optional verbosity control for GPT-5 models (Responses API `text.verbosity`).
|
||||
pub model_verbosity: Option<Verbosity>,
|
||||
|
||||
/// Base URL for requests to ChatGPT (as opposed to the OpenAI API).
|
||||
pub chatgpt_base_url: String,
|
||||
|
||||
/// Whether configuration or managed requirements explicitly selected the ChatGPT base URL.
|
||||
pub chatgpt_base_url_is_explicit: bool,
|
||||
|
||||
/// Whether aKode-owned clients should respect host system proxy settings.
|
||||
pub respect_system_proxy: bool,
|
||||
|
||||
@@ -3454,22 +3448,12 @@ impl Config {
|
||||
config_layer_stack.requirements(),
|
||||
&mut startup_warnings,
|
||||
);
|
||||
// Packaged defaults supply a URL even when no override was configured.
|
||||
let chatgpt_base_url_is_explicit =
|
||||
config_layer_stack.requirements().chatgpt_base_url.is_some()
|
||||
|| config_layer_stack
|
||||
.layers_high_to_low()
|
||||
.find(|layer| layer.config.get("chatgpt_base_url").is_some())
|
||||
.map_or(cfg.chatgpt_base_url.is_some(), |layer| {
|
||||
!matches!(layer.name, ConfigLayerSource::PackagedDefaults { .. })
|
||||
});
|
||||
// Destructure every field to ensure ConfigRequirements additions are
|
||||
// either applied above or handled while constructing the final Config.
|
||||
let ConfigRequirements {
|
||||
allowed_login_methods: _,
|
||||
allowed_chatgpt_workspaces: _,
|
||||
cli_auth_credentials_store,
|
||||
chatgpt_base_url: _,
|
||||
sqlite_home: _,
|
||||
unsafe_enforce_sqlite_journal_mode,
|
||||
log_dir: _,
|
||||
@@ -3976,7 +3960,6 @@ impl Config {
|
||||
feature_enabled: enable_network_proxy,
|
||||
features: cfg.features.as_ref(),
|
||||
candidate_permission_profile: &permission_profile,
|
||||
credential_broker_base_url: cfg.openai_base_url.as_deref(),
|
||||
});
|
||||
if cfg.approval_policy == Some(AskForApproval::UnlessTrusted) {
|
||||
return Err(std::io::Error::new(
|
||||
@@ -4734,9 +4717,6 @@ impl Config {
|
||||
model_reasoning_summary: cfg.model_reasoning_summary,
|
||||
model_catalog,
|
||||
model_verbosity: cfg.model_verbosity,
|
||||
chatgpt_base_url_is_explicit,
|
||||
// No ChatGPT backend default: empty unless explicitly configured.
|
||||
chatgpt_base_url: cfg.chatgpt_base_url.unwrap_or_default(),
|
||||
respect_system_proxy,
|
||||
apps_mcp_product_sku: cfg.apps_mcp_product_sku.clone(),
|
||||
responses_api_metadata: cfg.responses_api_metadata.unwrap_or_default(),
|
||||
@@ -5027,7 +5007,6 @@ impl Config {
|
||||
&& self.features.enabled(Feature::NetworkProxy),
|
||||
features: cfg.features.as_ref(),
|
||||
candidate_permission_profile: permission_profile,
|
||||
credential_broker_base_url: cfg.openai_base_url.as_deref(),
|
||||
});
|
||||
build_network_proxy_spec(
|
||||
prepared_network.configured_proxy,
|
||||
|
||||
@@ -78,7 +78,6 @@ pub struct NetworkConfigInputs<'a> {
|
||||
pub feature_enabled: bool,
|
||||
pub features: Option<&'a FeaturesToml>,
|
||||
pub candidate_permission_profile: &'a PermissionProfile,
|
||||
pub credential_broker_base_url: Option<&'a str>,
|
||||
}
|
||||
|
||||
/// The configured proxy before managed network requirements are applied.
|
||||
@@ -93,7 +92,6 @@ impl PreparedNetworkConfig {
|
||||
feature_enabled,
|
||||
features,
|
||||
candidate_permission_profile,
|
||||
credential_broker_base_url,
|
||||
} = inputs;
|
||||
if feature_enabled
|
||||
&& candidate_permission_profile
|
||||
@@ -107,7 +105,6 @@ impl PreparedNetworkConfig {
|
||||
}
|
||||
configured_proxy.enabled = true;
|
||||
}
|
||||
configured_proxy.set_credential_broker_openai_base_url(credential_broker_base_url);
|
||||
Self { configured_proxy }
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@ pub(super) fn apply_to_config(
|
||||
}
|
||||
|
||||
apply_exact!(cli_auth_credentials_store);
|
||||
apply_exact!(chatgpt_base_url);
|
||||
apply_exact!(sqlite_home);
|
||||
apply_exact!(log_dir);
|
||||
apply_exact!(model_catalog_json);
|
||||
|
||||
Reference in New Issue
Block a user