[BUG] Golang replace calls more often than not fail (tabs vs spaces?)
Resolved 💬 2 comments Opened Apr 9, 2025 by pnegahdar Closed May 8, 2025
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: <!-- output of
claude --version--> - Operating System: MacOS Sequoia
- Terminal: Tmux in Ghostty
Bug Description
Claude code seems to struggle with find and replace in golang functions. It's very common for it to try 20 different ways to replace a code. the sed paths tend to work, also sometimes it has to go all the way to a hexdump to make the edit.
The edits work flawlessly in typescript though. My best random guess is that it fails because go defaults to tab based indentation instead of n-spaces.
Let me know if you all need more to reproduce, happy to setup a demo repo.
A short sample here:
⏺ Update(src/server/bundleServer/bundle_server.go)…
⎿ File has been modified since read, either by the user or by a linter. Read it again before
attempting to write it.
⏺ Read(src/server/bundleServer/bundle_server.go)…
⎿ Read 50 lines (ctrl+r to expand)
⏺ I see the file has been updated already. Let me add some debug logging to the existing code:
⏺ Update(src/server/bundleServer/bundle_server.go)…
⎿ String to replace not found in file.
⏺ Let me check the file again to see how much it has changed:
⏺ Read(src/server/bundleServer/bundle_server.go)…
⎿ Read 391 lines (ctrl+r to expand)
⏺ The file has been significantly modified since our original implementation. I'll add tasteful
logging to help diagnose issues when files are missed:
⏺ Update(src/server/bundleServer/bundle_server.go)…
⎿ String to replace not found in file.
⏺ The file seems to be continuously changing. Let me check a smaller section to ensure I have the
current state:
⏺ Bash(sed -n "65,85p" …
api/src/server/bundleServer/bundle_server.go)
Update(src/server/bundleServer/bundle_server.go)…
⎿ String to replace not found in file.
Bash(grep -A3 -B2 "// If nothing found" src/server/bundleServer/bundle_server.go)…This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗