Lightweight coding agent that runs in your terminal
Rust
Redact auth tokens from app-server response logs (#39141)
Adam Perry @ OpenAI9a254ba1fa03
diff --git a/codex-rs/app-server-protocol/src/protocol/v2/account.rs b/codex-rs/app-server-protocol/src/protocol/v2/account.rsindex d42abf1de5..bbc7959674 100644--- a/codex-rs/app-server-protocol/src/protocol/v2/account.rs+++ b/codex-rs/app-server-protocol/src/protocol/v2/account.rs@@ -13,6 +13,7 @@ use codex_protocol::protocol::SpendControlLimitSnapshot as CoreSpendControlLimituse serde::Deserialize;use serde::Serialize;use std::collections::HashMap;+use std::fmt;#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]#[serde(tag = "type", rename_all = "camelCase")]@@ -277,7 +278,7 @@ pub struct ChatgptAuthTokensRefreshParams {pub previous_account_id: Option<String>,}-#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]+#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, TS)]#[serde(rename_all = "camelCase")]#[ts(export_to = "v2/")]pub struct ChatgptAuthTokensRefreshResponse {@@ -286,6 +287,16 @@ pub struct ChatgptAuthTokensRefreshResponse {pub chatgpt_plan_type: Option<String>,}+impl fmt::Debug for ChatgptAuthTokensRefreshResponse {+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {+ f.debug_struct("ChatgptAuthTokensRefreshResponse")+ .field("access_token", &"<redacted>")+ .field("chatgpt_account_id", &self.chatgpt_account_id)+ .field("chatgpt_plan_type", &self.chatgpt_plan_type)+ .finish()+ }+}+#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]#[serde(rename_all = "camelCase")]#[ts(export_to = "v2/")]diff --git a/codex-rs/app-server/src/message_processor.rs b/codex-rs/app-server/src/message_processor.rsindex 74fdbcfdf4..e6d82f010a 100644--- a/codex-rs/app-server/src/message_processor.rs+++ b/codex-rs/app-server/src/message_processor.rs@@ -815,7 +815,6 @@ impl MessageProcessor {/// Handle a standalone JSON-RPC response originating from the peer.pub(crate) async fn process_response(&self, response: JSONRPCResponse) {- tracing::info!("<- response: {:?}", response);let JSONRPCResponse { id, result, .. } = response;self.outgoing.notify_client_response(id, result).await}diff --git a/codex-rs/app-server/src/outgoing_message.rs b/codex-rs/app-server/src/outgoing_message.rsindex d0dc22a12a..262c674ae6 100644--- a/codex-rs/app-server/src/outgoing_message.rs+++ b/codex-rs/app-server/src/outgoing_message.rs@@ -386,14 +386,15 @@ impl OutgoingMessageSender {match entry {Some((id, entry)) => {let completed_at_ms = now_unix_timestamp_ms();- if let Ok(response) = entry.request.response_from_result(result.clone())- && !matches!(response, ServerResponse::PermissionsRequestApproval { .. })- {- self.analytics_events_client- .track_server_response(completed_at_ms, response);+ if let Ok(response) = entry.request.response_from_result(result.clone()) {+ tracing::info!("<- response: {response:?}");+ if !matches!(response, ServerResponse::PermissionsRequestApproval { .. }) {+ self.analytics_events_client+ .track_server_response(completed_at_ms, response);+ }}- if let Err(err) = entry.callback.send(Ok(result)) {- warn!("could not notify callback for {id:?} due to: {err:?}");+ if entry.callback.send(Ok(result)).is_err() {+ warn!("could not notify callback for {id:?}: receiver dropped");}}None => {