aws / aws/amazon-q-developer-cli

fs_write str_replace command frequently fails with tool cancellation

Aperta
#2,492 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Rust
Stelle
2k
Fork
439
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

Checks
Operating system

Linux 5.15.0-91-generic - Linux Mint 21.3

Expected behaviour

The fs_write tool with str_replace command should successfully replace text blocks, especially multi-line YAML content with proper indentation and special characters (quotes, colons, etc.)

Actual behaviour

The fs_write tool frequently gets cancelled during execution when attempting str_replace operations on:

  1. Multi-line YAML blocks with complex indentation
  2. Text containing quotes and special YAML characters
  3. Large text blocks requiring whitespace-sensitive matching
  4. GitHub Actions workflow files with input definitions

This results in "Tool use was cancelled by the user" errors even when the replacement appears valid.

[chat-transcript]

## 🔍 Phase 1: Fix main-deployment.yml YAML Structure

First, let me fix the corrupted YAML structure in the workflow inputs:
[Tool uses: fs_read]

I can see the problem clearly now. Let me fix the corrupted inputs section:
[Tool uses: fs_write]

Amazon Q is having trouble responding right now: 
   0: failed to print tool, `fs_write`: No such file or directory (os error 2)

Location:
   /codebuild/output/src3298519376/src/crates/q_chat/src/lib.rs:1019

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.


> Its seems that your fs_write tool has issues under some use cases. Lets document what those use cases are, submit feedback to AWS to fix them, and then try a different approach. I'm asking for this because you've had many failures of that tool so far today, and also recently in the past.

You're absolutely right! I've had multiple failures with the `fs_write` tool today, particularly with the `str_replace` command. Let me document the problematic use cases and report this issue, then use a different approach.

## 🐛 Documenting fs_write Tool Issues

Based on today's failures, here are the problematic use cases I've encountered:

### **Issue Pattern 1: Multi-line YAML replacements**
- **Problem**: When trying to replace multi-line YAML blocks with `str_replace`
- **Failure**: Tool gets cancelled, especially with complex indentation
- **Example**: Replacing workflow input sections with proper YAML structure

### **Issue Pattern 2: Large text blocks with special characters**
- **Problem**: Replacements involving quotes, colons, and YAML syntax
- **Failure**: Tool cancellation during execution
- **Example**: YAML workflow definitions with descriptions containing quotes

### **Issue Pattern 3: Whitespace-sensitive replacements**
- **Problem**: YAML requires exact whitespace matching, but tool struggles with this
- **Failure**: Either cancellation or incorrect matching
- **Example**: Indented YAML blocks in GitHub Actions workflows
[Tool uses: report_issue]

(...truncated)
Steps to reproduce
  1. Attempt to use fs_write with str_replace on multi-line YAML content
  2. Include text with quotes, colons, and indentation in old_str/new_str parameters
  3. Try to replace GitHub Actions workflow input sections
  4. Tool gets cancelled during execution

This has occurred multiple times during a single chat session when trying to fix corrupted YAML workflow files.

Environment
[q-details]
version = "1.9.1"
hash = "5d2c2807cab9bc6c9dc5fcd05f92c7a979e8a4f7"
date = "2025-04-29T06:25:24.357798Z (98d ago)"
variant = "full"

[system-info]
chip = "AMD Ryzen 7 4700U with Radeon Graphics"
total-cores = 8
memory = "15.04 GB"

[system-info.os.linux]
kernel_version = "5.15.0-91-generic"
id = "linuxmint"
name = "Linux Mint"
pretty_name = "Linux Mint 21.3"
version_id = "21.3"
version = "21.3 (Virginia)"

[environment]
cwd = "/home/USER"
cli-path = "/home/USER"
os = "Linux"
shell-path = "/usr/bin/bash"
shell-version = "5.1.16"
terminal = "Xfce Terminal"
install-method = "unknown"

[env-vars]
DISPLAY = ":0.0"
GTK_IM_MODULE = "ibus"
PATH = "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/home/USER/.nvm/versions/node/v20.4.0/bin:/home/USER/.local/bin:/home/USER/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
QT_IM_MODULE = "ibus"
SHELL = "/bin/bash"
TERM = "xterm-256color"
XDG_CURRENT_DESKTOP = "XFCE"
XDG_SESSION_DESKTOP = "xfce"
XDG_SESSION_TYPE = "x11"
XMODIFIERS = "@im=ibus"

[chat-settings]
interactive=true

[chat-trusted_tools]
execute_bash=true
fs_write=true

[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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia con l’errore fs_write segnalato in crates/q_chat/src/lib.rs:1019, quindi riproduci i casi di str_replace usando gli input YAML su più righe, di indentazione, di virgolette e di caratteri speciali elencati. Usa q doctor e q restart come controlli iniziali. Il lavoro è completato quando le sostituzioni interessate non producono più errori di tool-cancellation o errori fs_write correlati negli scenari documentati.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
rust
Ambito
cli, devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.