Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions codex-rs/rmcp-client/src/rmcp_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,14 +120,17 @@ impl RmcpClient {
url: &str,
bearer_token: Option<String>,
) -> Result<Self> {
let initial_tokens = match load_oauth_tokens(server_name, url) {
Ok(tokens) => tokens,
Err(err) => {
warn!("failed to read tokens for server `{server_name}`: {err}");
None
}
let initial_oauth_tokens = match bearer_token {
Some(_) => None,
None => match load_oauth_tokens(server_name, url) {
Ok(tokens) => tokens,
Err(err) => {
warn!("failed to read tokens for server `{server_name}`: {err}");
None
}
},
};
let transport = if let Some(initial_tokens) = initial_tokens.clone() {
let transport = if let Some(initial_tokens) = initial_oauth_tokens.clone() {
let (transport, oauth_persistor) =
create_oauth_transport_and_runtime(server_name, url, initial_tokens).await?;
PendingTransport::StreamableHttpWithOAuth {
Expand All @@ -137,7 +140,7 @@ impl RmcpClient {
} else {
let mut http_config = StreamableHttpClientTransportConfig::with_uri(url.to_string());
if let Some(bearer_token) = bearer_token {
http_config = http_config.auth_header(format!("Bearer {bearer_token}"));
http_config = http_config.auth_header(bearer_token);
Comment on lines 140 to +143
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P0 Badge Don’t move bearer_token before building HTTP config

In new_streamable_http_client the initial OAuth tokens are computed with match bearer_token { … } and later the same bearer_token is matched again to populate the auth header. Because Option<String> is not Copy, the first match moves bearer_token and the later if let Some(bearer_token) = bearer_token cannot compile (value used after move). This commit therefore fails to build. Consider matching on a reference (bearer_token.as_ref()) or cloning before the first match.

Useful? React with 👍 / 👎.

}

let transport = StreamableHttpClientTransport::from_config(http_config);
Expand Down
Loading