aws / aws/amazon-q-developer-cli
Improve error messaging for authentication failures
- Dominant language
- Rust
- Stars
- 2k
- Forks
- 439
- PR merge metrics
- No merged PRs in 30d
Description
### Checks
- [x] I have searched [github.com/aws/amazon-q-developer-cli/issues](https://github.com/aws/amazon-q-developer-cli/issues?q=) and there are no duplicates of my issue
- [x] I have run `q doctor` in the affected terminal session
- [x] I have run `q restart` and replicated the issue again
### Operating system
macOS 15.7.0 (24G222)
### Expected behaviour
When authentication tokens expire or become invalid, Q CLI should display a clear, actionable error message like "Authentication expired. Please run `q logout && q login` to refresh your credentials."
### Actual behaviour
Q CLI shows cryptic network error messages like "dispatch failure (io error): an i/o error occurred: error sending request for url (https://q.us-east-1.amazonaws.com/)" which don't indicate the root cause is authentication.
```
[chat-transcript]
> can you point me to a quick how-to for creating
Amazon Q is having trouble responding right now:
0: Failed to send the request: dispatch failure (io error): an i/o error occurred: error sending request for url (https://q.us-east-1.amazonaws.com/)
1: dispatch failure (io error): an i/o error occurred: error sending request for url (https://q.us-east-1.amazonaws.com/)
2: dispatch failure
3: io error
4: an i/o error occurred: error sending request for url (https://q.us-east-1.amazonaws.com/)
Location:
crates/chat-cli/src/cli/chat/mod.rs:1073
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
> q what's wrong with you? I'm getting "mazon Q is having trouble responding right now: >
0: Failed to send the request: dispatch failure (io error): an i/o error occurred: error sending request for url (https://q.us-east-1.amazonaws.com/)>
1: dispatch failure (io error): an i/o error occurred: error sending request for url (https://q.us-east-1.amazonaws.com/)>
2: dispatch failure>
3: io error>
4: an i/o error occurred: error sending request for url (https://q.us-east-1.amazonaws.com/)>
>
Location:>
crates/chat-cli/src/cli/chat/mod.rs:1073>
>
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.>
Run with RUST_BACKTRACE=full to include source snippets." and ">
Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.>
Run with RUST_BACKTRACE=full to include source snippets."
This looks like a network connectivity issue with the Amazon Q service. Let's troubleshoot:
[Tool uses: execute_bash]
The service endpoint is reachable (getting a 404 is normal for the base URL). Let's check your Q CLI authentication status:
[Tool uses: execute_bash]
[Tool uses: execute_bash]
[Tool uses: execute_bash]
The issue appears to be authentication-related. Try re-authenticating:
[Tool uses: execute_bash]
You're logged in but having connection issues. Let's try logging out and back in:
[Tool uses: execute_bash]
Great! You're now logged back in successfully. The authentication refresh should resolve the connection issues you were experiencing. Try using Q CLI chat now - the "dispatch failure" and "io error" messages should be gone.
The issue was likely expired or corrupted authentication tokens that needed to be refreshed.
[Tool uses: none]
> it would help to get a more actionable error message. worth a ticket to q cli developers, or is it me to getting it?
You're absolutely right - that error message is not user-friendly at all. A good error message for authentication issues should say something like:
"Authentication expired. Please run `q logout && q login` to refresh your credentials."
Instead of the cryptic:
"dispatch failure (io error): an i/o error occurred: error sending request for url"
This is definitely worth a ticket to the Q CLI developers. You can file it using:
[Tool uses: report_issue]
(...truncated)
```
### Steps to reproduce
1. Use Q CLI until authentication tokens expire
2. Try to use chat functionality
3. Observe unhelpful error message instead of clear authentication guidance
### Environment
```yaml
[q-details]
version = "1.16.2"
hash = "c4c80bb44cb22b6e19129ed7475f2793ff20135d"
date = "2025-09-19T01:27:56.356289Z (4d ago)"
[system-info]
os = "macOS 15.7.0 (24G222)"
chip = "Apple M2 Pro"
total-cores = 10
memory = "16.00 GB"
[environment]
cwd = "/Users/USER"
cli-path = "/Users/USER"
install-method = "unknown"
[env-vars]
PATH = "/Users/USER/.local/bin:/Users/USER/.toolbox/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/USER/.local/bin"
QTERM_SESSION_ID = "8dde585ff7f84bac80660af3f35b15c5"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.16.2"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "org.tabby"
[chat-settings]
[chat-trusted_tools]
execute_bash=trusted
[chat-failed_request_ids]
none
[chat-context]
current_profile=q_cli_default
profile_context=
AmazonQ.md
AGENTS.md
README.md
.amazonq/rules/**/*.md
files=none
```
Contributor guide
Assessment
This issue has not been assessed yet.