Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion crates/chat-cli/src/api_client/clients/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl Client {
.http_client(crate::aws_common::http_client::client())
.interceptor(OptOutInterceptor::new(database))
.interceptor(UserAgentOverrideInterceptor::new())
.bearer_token_resolver(BearerResolver::new(database).await?)
.bearer_token_resolver(BearerResolver)
.app_name(app_name())
.endpoint_url(endpoint.url())
.build();
Expand Down
2 changes: 1 addition & 1 deletion crates/chat-cli/src/api_client/clients/streaming_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl StreamingClient {
.http_client(crate::aws_common::http_client::client())
.interceptor(OptOutInterceptor::new(database))
.interceptor(UserAgentOverrideInterceptor::new())
.bearer_token_resolver(BearerResolver::new(database).await?)
.bearer_token_resolver(BearerResolver)
.app_name(app_name())
.endpoint_url(endpoint.url())
.stalled_stream_protection(stalled_stream_protection_config())
Expand Down
15 changes: 3 additions & 12 deletions crates/chat-cli/src/auth/builder_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,17 +518,7 @@ pub async fn logout(database: &mut Database) -> Result<(), AuthError> {
}

#[derive(Debug, Clone)]
pub struct BearerResolver {
token: Option<BuilderIdToken>,
}

impl BearerResolver {
pub async fn new(database: &mut Database) -> Result<Self, AuthError> {
Ok(Self {
token: BuilderIdToken::load(database).await?,
})
}
}
pub struct BearerResolver;

impl ResolveIdentity for BearerResolver {
fn resolve_identity<'a>(
Expand All @@ -537,7 +527,8 @@ impl ResolveIdentity for BearerResolver {
_config_bag: &'a ConfigBag,
) -> IdentityFuture<'a> {
IdentityFuture::new_boxed(Box::pin(async {
match &self.token {
let database = Database::new().await?;
match BuilderIdToken::load(&database).await? {
Some(token) => Ok(Identity::new(
Token::new(token.access_token.0.clone(), Some(token.expires_at.into())),
Some(token.expires_at.into()),
Expand Down
6 changes: 1 addition & 5 deletions crates/chat-cli/src/cli/chat/mcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,7 @@ mod tests {

// profile
let p = resolve_scope_profile(&ctx, Some(Scope::Profile), Some(&"qa")).unwrap();
assert_eq!(
p,
profile_mcp_config_path(&ctx, &"qa").unwrap(),
"profile path mismatch"
);
assert_eq!(p, profile_mcp_config_path(&ctx, "qa").unwrap(), "profile path mismatch");
}

#[ignore = "TODO: fix in CI"]
Expand Down
Loading