mirror of
https://github.com/openai/codex.git
synced 2026-10-24 18:18:41 +00:00
Remove the 1 MiB response limit for explicit model catalogs (#56525)
## What changed Fetch catalogs configured with `model_catalog_url` without a response-body size limit, allowing responses larger than 1 MiB. Remove the oversized-response rejection test and update the catalog client documentation to drop the limit requirement. GitOrigin-RevId: acd0dbbac5d548596b50faa309496de2db3588df
This commit is contained in:
committed by
copyberry
parent
b82d542aef
commit
adca78ddae
@@ -92,8 +92,8 @@ impl<T: HttpTransport> ModelsClient<T> {
|
||||
|
||||
/// Fetches a catalog using the provider's auth and retry policy without decoding it.
|
||||
///
|
||||
/// Callers accepting provider-controlled catalogs must set a response-body limit
|
||||
/// and validate the native response without including raw values in diagnostics.
|
||||
/// Callers accepting provider-controlled catalogs must validate the native response
|
||||
/// without including raw values in diagnostics.
|
||||
pub async fn list_models_raw(
|
||||
&self,
|
||||
request_url: String,
|
||||
|
||||
@@ -44,8 +44,6 @@ use crate::combined_auth::compose_auth;
|
||||
|
||||
const MODELS_REFRESH_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
const MODELS_ENDPOINT: &str = "/models";
|
||||
// Bound downloads from explicitly configured catalogs before decoding or caching them.
|
||||
const MAX_MODEL_CATALOG_BYTES: usize = 1024 * 1024;
|
||||
|
||||
/// Provider-owned OpenAI-compatible `/models` endpoint.
|
||||
#[derive(Debug)]
|
||||
@@ -157,13 +155,12 @@ impl OpenAiModelsEndpoint {
|
||||
.await?;
|
||||
let client = ModelsClient::new(transport, api_provider, api_auth)
|
||||
.with_telemetry(Some(request_telemetry));
|
||||
let response_body_limit_bytes = self
|
||||
.provider_info
|
||||
.model_catalog_url
|
||||
.as_ref()
|
||||
.map(|_| MAX_MODEL_CATALOG_BYTES);
|
||||
client
|
||||
.list_models(request_url, HeaderMap::new(), response_body_limit_bytes)
|
||||
.list_models(
|
||||
request_url,
|
||||
HeaderMap::new(),
|
||||
/*response_body_limit_bytes*/ None,
|
||||
)
|
||||
.await
|
||||
.map_err(|mut error| {
|
||||
if self.provider_info.model_catalog_url.is_some()
|
||||
@@ -437,7 +434,6 @@ mod tests {
|
||||
use codex_models_manager::model_info::model_info_from_slug;
|
||||
use codex_protocol::auth::AuthMode;
|
||||
use codex_protocol::config_types::ModelProviderAuthInfo;
|
||||
use codex_protocol::error::CodexErrorDetails;
|
||||
use codex_protocol::openai_models::ModelVisibility;
|
||||
use codex_protocol::openai_models::ModelsResponse;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -932,41 +928,6 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn explicit_catalog_rejects_oversized_response() {
|
||||
let server = MockServer::start().await;
|
||||
let mut body = br#"{"models":[]}"#.to_vec();
|
||||
body.resize(MAX_MODEL_CATALOG_BYTES + 1, b' ');
|
||||
Mock::given(method("GET"))
|
||||
.and(path("/codex/models"))
|
||||
.respond_with(ResponseTemplate::new(/*s*/ 200).set_body_bytes(body))
|
||||
.expect(1)
|
||||
.mount(&server)
|
||||
.await;
|
||||
let endpoint = OpenAiModelsEndpoint::new(
|
||||
ModelProviderInfo {
|
||||
model_catalog_url: Some(format!("{}/codex/models", server.uri()).into()),
|
||||
..ModelProviderInfo::default()
|
||||
},
|
||||
/*auth_manager*/ None,
|
||||
/*gateway_auth_manager*/ None,
|
||||
);
|
||||
let error = endpoint
|
||||
.list_models(
|
||||
"1.2.3",
|
||||
HttpClientFactory::new(OutboundProxyPolicy::ReqwestDefault),
|
||||
)
|
||||
.await
|
||||
.expect_err("oversized catalog should be rejected");
|
||||
let CodexErrorDetails::InvalidRequest(message) = error.details() else {
|
||||
panic!("expected a response-size error, got {error:?}");
|
||||
};
|
||||
assert_eq!(
|
||||
message,
|
||||
&format!("response body exceeds the {MAX_MODEL_CATALOG_BYTES} byte limit")
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn explicit_catalog_rejects_redirects_without_forwarding_provider_credentials() {
|
||||
let server = MockServer::start().await;
|
||||
|
||||
Reference in New Issue
Block a user