aws / aws/amazon-q-developer-cli
Error when `q chat` attempts to read an empty file using `fs_read`
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Rust
- Sterne
- 2k
- Forks
- 439
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
Checks
- I have searched github.com/aws/amazon-q-developer-cli/issues and there are no duplicates of my issue
- I have run
q doctorin the affected terminal session - I have run
q restartand replicated the issue again
Operating system
macOS 15.4.1 (24E263)
Expected behaviour
fs_read has doesn't seem to handle empty files very well.
Probably need to check if line_count is empty and then either give a more sensible error message or even better signal to the agent that the file is indeed empty. Unfortunately there doesn't seem to be a OutputKind of Empty. I wonder what the agent would do if you just returned a empty string?
Actual behaviour
Execution failed after 0.0s:
starting index: 1 is outside of the allowed range: (0, 0)
The error is generated in https://github.com/aws/amazon-q-developer-cli/blob/main/crates/q_chat/src/tools/fs_read.rs#L145
Steps to reproduce
mkdir -p ~/tmp/test
cd ~/tmp/test/
touch __python_file_.py
q chat
Give q the prompt
summarize the file called '__python_file_.py'
Results
I'll help you summarize the file __python_file_.py. First, let me check if this file exists in your current directory.
🛠️ Using tool: fs_read (trusted)
⋮
● Reading file: __python_file_.py, from line 1 to 1
⋮
● Execution failed after 0.0s:
starting index: 1 is outside of the allowed range: (0, 0)
It seems the file __python_file_.py doesn't exist in your current directory. Let me check if it exists elsewhere by listing the files in your current directory.
🛠️ Using tool: fs_read (trusted)
⋮
● Reading directory: . with maximum depth of 0
⋮
● Completed in 0.0s
I see the file __python_file_.py exists in your current directory, but it appears to be empty (0 bytes). The file was created today at 00:13, but it doesn't contain any code or content to summarize.
Would you like me to:
1. Create some Python code in this file?
2. Check if you meant a different Python file?
3. Help you with something else related to this file?
Environment
<This will be visible to anyone. Do not include personal or sensitive information>
[q-details]
version = "1.9.1"
hash = "5d2c2807cab9bc6c9dc5fcd05f92c7a979e8a4f7"
date = "2025-04-29T06:22:42.917989Z (6d ago)"
variant = "full"
[system-info]
os = "macOS 15.4.1 (24E263)"
chip = "Apple M3 Pro"
total-cores = 12
memory = "36.00 GB"
[environment]
cwd = "/Users/USER/tmp/test"
cli-path = "/Users/USER/tmp/test"
os = "Mac"
shell-path = "/bin/zsh"
shell-version = "5.9"
terminal = "iTerm 2"
install-method = "brew"
[env-vars]
PATH = "/Users/USER/.toolbox/bin:/usr/local/sbin:/Users/USER/.cargo/bin:/Users/USER/.rbenv/shims:/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:/Applications/Wireshark.app/Contents/MacOS:/Users/USER/.local/bin:/Users/USER/.cargo/bin:/Applications/iTerm.app/Contents/Resources/utilities:/Users/USER/Library/Application Support/JetBrains/Toolbox/scripts:/apollo/env/SDETools/bin:/Users/USER/bin:/Users/USER/workspace/Git-review-tools/src/Git-review-tools/bin:/Users/USER/workspace/LazyCR/target/release"
QTERM_SESSION_ID = "b2934faa68f04faaa79b3441fe05c3df"
Q_SET_PARENT_CHECK = "1"
Q_TERM = "1.9.1"
SHELL = "/bin/zsh"
TERM = "xterm-256color"
__CFBundleIdentifier = "com.googlecode.iterm2"
[chat-settings]
interactive=true
[chat-trusted_tools]
[chat-failed_request_ids]
none
[chat-context]
current_profile=default
profiles=
default
global_context=
.amazonq/rules/**/*.md
README.md
AmazonQ.md
profile_context=none
files=none
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne in crates/q_chat/src/tools/fs_read.rs etwa bei Zeile 145 und reproduziere das Problem mit einer leeren Datei unter Verwendung des dokumentierten q chat-Prompts. Verfolge nach, wie ein leerer line_count die Bereichsprüfung erreicht. Die Aufgabe ist abgeschlossen, wenn fs_read nicht mehr den Fehler wegen eines Bereichs außerhalb des gültigen Bereichs erzeugt und der Agent eine sinnvolle Anzeige erhält, dass die Datei leer ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- rust
- Bereich
- cli
- Issue-Typ
- Bug
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100