mirror of
https://github.com/openai/codex.git
synced 2026-11-17 22:10:37 +00:00
## Why Status line provider discovery failures were silently ignored, and startup lookup timeouts appeared as unavailable providers. ## What changed - Show incomplete provider discovery in the warnings viewer, with sanitized server names, bounded summaries, and no raw RPC error details. Preserve the warning across canceled scans and clear it after a successful scan. - Share a single five-second startup deadline across provider lookup retries and report timed-out lookups as `Status line timed out`. ## Testing Add coverage for discovery warning rendering and lifecycle, and for a hung lookup retry exhausting the remaining startup deadline. Update the startup timeout expectation. GitOrigin-RevId: 0403af2ed688c31c175d1b5c47d2cdd4cd355653
75 lines
2.2 KiB
Rust
75 lines
2.2 KiB
Rust
//! Classify provider failures without carrying raw RPC errors or resource content.
|
|
|
|
use super::UiTree;
|
|
use codex_app_server_client::TypedRequestError;
|
|
use codex_app_server_protocol::McpResourceContent;
|
|
|
|
#[derive(Debug, PartialEq, Eq, thiserror::Error)]
|
|
pub(super) enum ReadIssue {
|
|
#[error("timed out after 1 second")]
|
|
TimedOut,
|
|
#[error("failed in transport")]
|
|
Transport,
|
|
#[error("was rejected with code {0}")]
|
|
Rejected(i64),
|
|
#[error("returned an invalid app-server response")]
|
|
Response,
|
|
#[error("expected exactly one text resource")]
|
|
Envelope,
|
|
#[error("resource URI differs from the advertised URI")]
|
|
Uri,
|
|
#[error("expected application/json on the resource")]
|
|
Mime,
|
|
#[error("resource text is not a valid, bounded UI tree")]
|
|
Tree,
|
|
}
|
|
|
|
impl From<TypedRequestError> for ReadIssue {
|
|
fn from(error: TypedRequestError) -> Self {
|
|
match error {
|
|
TypedRequestError::Transport { .. } => Self::Transport,
|
|
TypedRequestError::Server { source, .. } => Self::Rejected(source.code),
|
|
TypedRequestError::Deserialize { .. } => Self::Response,
|
|
}
|
|
}
|
|
}
|
|
|
|
#[derive(Debug, thiserror::Error)]
|
|
pub(super) enum Failure {
|
|
#[error("The selected provider is unavailable.")]
|
|
LookupUnavailable,
|
|
#[error("The selected provider lookup timed out.")]
|
|
LookupTimedOut,
|
|
#[error("The displayed thread could not supply its current status line state.")]
|
|
Snapshot,
|
|
#[error("Resource read: {0}.")]
|
|
Read(#[from] ReadIssue),
|
|
}
|
|
|
|
pub(super) fn decode_tree(uri: &str, contents: &[McpResourceContent]) -> Result<UiTree, ReadIssue> {
|
|
let [
|
|
McpResourceContent::Text {
|
|
uri: returned_uri,
|
|
mime_type,
|
|
text,
|
|
..
|
|
},
|
|
] = contents
|
|
else {
|
|
return Err(ReadIssue::Envelope);
|
|
};
|
|
if uri != returned_uri {
|
|
return Err(ReadIssue::Uri);
|
|
}
|
|
let media_type = mime_type
|
|
.as_deref()
|
|
.unwrap_or_default()
|
|
.split(';')
|
|
.next()
|
|
.unwrap_or_default();
|
|
if !media_type.trim().eq_ignore_ascii_case("application/json") {
|
|
return Err(ReadIssue::Mime);
|
|
}
|
|
text.parse().map_err(|_| ReadIssue::Tree)
|
|
}
|