Add auth 401 recovery observability to client bug reports#14611
Add auth 401 recovery observability to client bug reports#14611
Conversation
a8d6e5e to
ca2ad71
Compare
Add client-visible auth observability for 401 recovery, endpoint classification, and geo-denial diagnosis without changing auth behavior. Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
7407e72 to
0dca1e8
Compare
Keep auth_401_* as the preserved original unauthorized context while still recording the follow-up request's own ids and auth classification in auth_* fields. Co-authored-by: Codex <noreply@openai.com>
Update auth_401 feedback tags as a complete latest-401 snapshot so missing fields from a later unauthorized response clear older session metadata. Co-authored-by: Codex <noreply@openai.com>
Keep the latest unauthorized feedback fields together as one snapshot in core, then flatten them only at the Sentry feedback tag boundary. Co-authored-by: Codex <noreply@openai.com>
Keep the collab tool spec test aligned with current main by including the wait tool in the expected set. Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
Co-authored-by: Codex <noreply@openai.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 3a6eedfda9
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
codex-rs/core/src/client.rs
Outdated
| error_message.as_deref(), | ||
| connection_reused, | ||
| ); | ||
| crate::feedback_tags!(auth_connection_reused = connection_reused); |
There was a problem hiding this comment.
Emit complete feedback tags for websocket requests
ApiTelemetry::on_ws_request only writes auth_connection_reused. On reused sockets, connect_websocket is not called, so endpoint and other auth fields are left at whatever previous request wrote (e.g. /models or /responses/compact). This can misclassify websocket bug-report tags and hide the true failing route.
Useful? React with 👍 / 👎.
| let api_provider = self.provider.to_api_provider(auth_mode)?; | ||
| let api_auth = auth_provider_from_auth(auth.clone(), &self.provider)?; | ||
| let transport = ReqwestTransport::new(build_reqwest_client()); | ||
| let client = ModelsClient::new(transport, api_provider, api_auth); | ||
| let request_telemetry: Arc<dyn RequestTelemetry> = Arc::new(ModelsRequestTelemetry { | ||
| auth_mode: auth_mode.map(|mode| TelemetryAuthMode::from(mode).to_string()), | ||
| auth_header_attached: api_auth.auth_header_attached(), |
There was a problem hiding this comment.
Derive /models auth.mode from actual request auth
fetch_and_update_models sets telemetry auth_mode from self.auth_manager.auth_mode(), but the actual auth used is api_auth from auth_provider_from_auth(...). When provider API-key auth is active without matching auth-manager mode, /models telemetry/feedback can report empty or wrong auth.mode despite an attached auth header.
Useful? React with 👍 / 👎.
etraut-openai
left a comment
There was a problem hiding this comment.
Overall, looks good. The telemetry additions to the auth module, in particular, are going to come in handy for not only the 401 issue but also some of the token refresh bugs we've been playing whack-a-mole with for a while.
Before committing, there are some clippy errors to fix. Plus, there are some codex code review errors that look like legit (but perhaps edge-case) problems. I recommend running "codex review" a few more times to see if it finds anything more.
Thanks for doing this!
Co-authored-by: Codex <noreply@openai.com>
Fixed the Codex Review and Clippy. Thank you for the review, Eric! |
CXC-392
With 401

Without 401

Summary
auth_401_*while keeping follow-up result tags separate.Rationale (from spec findings)
Scope
codex-rs/core,codex-rs/codex-api, andcodex-rs/otel, including Sentry feedback tag surfacing.Trade-offs
Client follow-up
device_idremains intentionally separate until there is a safe existing source on the feedback upload path.Testing
cargo test -p codex-core emit_feedback_request_tags_cargo test -p codex-core emit_feedback_auth_recovery_tags_cargo test -p codex-core auth_request_telemetry_context_tracks_attached_auth_and_retry_phasecargo test -p codex-core websocket_session_tracks_connection_reusecargo test -p codex-core extract_response_debug_context_decodes_identity_headerscargo test -p codex-core identity_auth_detailscargo test -p codex-otel otel_export_routing_policy_routes_api_request_auth_observabilitycargo test -p codex-otel otel_export_routing_policy_routes_websocket_connect_auth_observabilitycargo test -p codex-otel otel_export_routing_policy_routes_websocket_request_transport_observability