Skip to content

Commit 56ea77e

Browse files
committed
Merge remote-tracking branch 'origin/main' into bskiser/add-agent-crate
2 parents 9be36ec + dd12213 commit 56ea77e

4 files changed

Lines changed: 58 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- **macOS**:
66
- **DMG**: [Download now](https://desktop-release.q.us-east-1.amazonaws.com/latest/Amazon%20Q.dmg)
7+
- **HomeBrew**: ```brew install --cask amazon-q ```
78
- **Linux**:
89
- [Ubuntu/Debian](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html#command-line-installing-ubuntu)
910
- [AppImage](https://docs.aws.amazon.com/amazonq/latest/qdeveloper-ug/command-line-installing.html#command-line-installing-appimage)

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,26 @@ impl ChatSession {
832832
}
833833

834834
let (context, report, display_err_message) = match err {
835+
ChatError::Auth(AuthError::NoToken) => {
836+
execute!(
837+
self.stderr,
838+
style::SetAttribute(Attribute::Bold),
839+
StyledText::error_fg(),
840+
style::Print("Authentication Error\n"),
841+
StyledText::reset_attributes(),
842+
StyledText::reset(),
843+
style::Print("\nYour login session has expired. Please log in again using:\n\n"),
844+
StyledText::success_fg(),
845+
style::Print(" q login\n\n"),
846+
StyledText::reset(),
847+
)?;
848+
849+
self.conversation
850+
.append_transcript("Authentication expired - please log in again".to_string());
851+
852+
self.inner = Some(ChatState::Exit);
853+
return Ok(());
854+
},
835855
ChatError::Interrupted { tool_uses: ref inter } => {
836856
execute!(self.stderr, style::Print("\n\n"))?;
837857

crates/chat-cli/src/constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ pub mod tips {
272272
StyledText::command("MCP servers")
273273
),
274274
format!(
275-
"You can specify wait time (in ms) for mcp server loading with {}. Servers that takes longer than the specified time will continue to load in the background. Use /tools to see pending servers.",
275+
"You can specify wait time (in ms) for mcp server loading with {}. Servers that take longer than the specified time will continue to load in the background. Use /tools to see pending servers.",
276276
StyledText::command("q settings mcp.initTimeout {timeout in int}")
277277
),
278278
format!(

crates/chat-cli/src/mcp_client/client.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,8 +458,14 @@ impl McpClientService {
458458
..
459459
} = &self.config;
460460

461+
// Process environment variables in headers
462+
let mut processed_headers = headers.clone();
463+
for (_, value) in processed_headers.iter_mut() {
464+
*value = substitute_env_vars(value, &os.env);
465+
}
466+
461467
let http_service_builder =
462-
HttpServiceBuilder::new(url, os, url, *timeout, scopes, headers, oauth, messenger);
468+
HttpServiceBuilder::new(url, os, url, *timeout, scopes, &processed_headers, oauth, messenger);
463469

464470
let (service, auth_client_wrapper) = http_service_builder.try_build(&self).await?;
465471

@@ -673,4 +679,33 @@ mod tests {
673679
assert_eq!(env_vars.get("KEY1").unwrap(), "Value is test_value");
674680
assert_eq!(env_vars.get("KEY2").unwrap(), "No substitution");
675681
}
682+
683+
#[tokio::test]
684+
async fn test_http_headers_env_var_processing() {
685+
let os = Os::new().await.unwrap();
686+
unsafe {
687+
os.env.set_var("GITHUB_TOKEN", "github_pat_test123");
688+
os.env.set_var("API_KEY", "secret_key_456");
689+
}
690+
691+
// Simulate HTTP headers with environment variables
692+
let mut headers = HashMap::new();
693+
headers.insert("Authorization".to_string(), "Bearer ${env:GITHUB_TOKEN}".to_string());
694+
headers.insert("X-API-Key".to_string(), "${env:API_KEY}".to_string());
695+
headers.insert("Content-Type".to_string(), "application/json".to_string());
696+
697+
// Process headers (same logic as in HTTP transport)
698+
let mut processed_headers = headers.clone();
699+
for (_, value) in processed_headers.iter_mut() {
700+
*value = substitute_env_vars(value, &os.env);
701+
}
702+
703+
// Verify environment variables were substituted
704+
assert_eq!(
705+
processed_headers.get("Authorization").unwrap(),
706+
"Bearer github_pat_test123"
707+
);
708+
assert_eq!(processed_headers.get("X-API-Key").unwrap(), "secret_key_456");
709+
assert_eq!(processed_headers.get("Content-Type").unwrap(), "application/json");
710+
}
676711
}

0 commit comments

Comments
 (0)