mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +00:00
Propagate authentication header failures before sending requests (#55607)
## Why Synchronous auth header construction could silently return no credentials when managed authentication became unavailable. Callers need an error to avoid sending requests with missing or partial authentication. ## What changed - Make `AuthProvider::add_auth_headers`, `to_auth_headers`, and auth header telemetry fallible, and propagate failures through request and WebSocket setup. - Return a transient error when managed authentication is unavailable, and preserve network policy denials through auth error conversion. - Retry transient MCP authentication errors while treating build errors and policy denials as terminal. - Cancel local MCP event streams before resolving authentication so cleanup still works when credentials become unavailable. ## Testing Add regression coverage for rejected partial authentication, async header resolution, terminal auth errors without sending requests, managed account changes, MCP retry classification, and local stream cancellation after authentication becomes unavailable. GitOrigin-RevId: 39d981e232cba1e302de502a2fa6239101114ed1
This commit is contained in:
@@ -64,7 +64,7 @@ pub async fn search_remote_plugins(
|
||||
config.http_request(Method::GET, &url),
|
||||
auth,
|
||||
&config.product_sku,
|
||||
);
|
||||
)?;
|
||||
let response: RemotePluginListResponse = send_and_decode(request, &url_for_error)
|
||||
.await
|
||||
.map_err(|error| match error {
|
||||
|
||||
@@ -289,7 +289,7 @@ pub async fn delete_remote_plugin_share(
|
||||
config.http_request(Method::DELETE, &url),
|
||||
auth,
|
||||
&config.product_sku,
|
||||
);
|
||||
)?;
|
||||
send_and_expect_status(request, &url, &[StatusCode::NO_CONTENT]).await?;
|
||||
if let Err(err) = local_paths::remove_plugin_share_local_path(codex_home, remote_plugin_id) {
|
||||
warn!(
|
||||
@@ -326,7 +326,7 @@ pub async fn update_remote_plugin_share_targets(
|
||||
config.http_request(Method::PUT, &url),
|
||||
auth,
|
||||
&config.product_sku,
|
||||
)
|
||||
)?
|
||||
.json(&RemotePluginShareUpdateTargetsRequest {
|
||||
discoverability,
|
||||
targets,
|
||||
@@ -401,7 +401,7 @@ async fn get_created_workspace_plugins_page(
|
||||
config.http_request(Method::GET, &url),
|
||||
auth,
|
||||
&config.product_sku,
|
||||
);
|
||||
)?;
|
||||
send_and_decode(request, &url).await
|
||||
}
|
||||
|
||||
@@ -418,7 +418,7 @@ async fn create_workspace_plugin_upload(
|
||||
config.http_request(Method::POST, &url),
|
||||
auth,
|
||||
&config.product_sku,
|
||||
)
|
||||
)?
|
||||
.json(&RemoteWorkspacePluginUploadUrlRequest {
|
||||
filename,
|
||||
mime_type: "application/gzip",
|
||||
@@ -480,7 +480,7 @@ async fn finalize_workspace_plugin_upload(
|
||||
config.http_request(Method::POST, &url),
|
||||
auth,
|
||||
&config.product_sku,
|
||||
)
|
||||
)?
|
||||
.json(&body);
|
||||
send_and_decode(request, &url).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user