-
Notifications
You must be signed in to change notification settings - Fork 193
editCode tool fails with empty selectors on large Java files #7073
Description
Before opening, please confirm:
Operating System
Windows 10
Kiro Version
0.11.63
Bug Description
The editCode tool (AST-based code editing) has multiple issues when operating on large Java files (~390+ lines):
Issue 1: Empty selectors - insert_node/replace_node fail
All selector formats return an empty list:
Error: Could not find target: AffiliateTradePanelServiceImpl. Available selectors:
Tried selectors:
- Unscoped method name:
checkAffiliateToPermission - Scoped:
AffiliateTradePanelServiceImpl.checkAffiliateToPermission - Class name:
AffiliateTradePanelServiceImpl
Issue 2: delete_node corrupts file
delete_node with selector AffiliateTradePanelServiceImpl.healthCheck reported success but actually deleted the entire class body, leaving only imports and a stray }. File had to be restored via git checkout.
Issue 3: False negative on write verification
When using insert_node, the tool reports Write verification failed - changes were not applied to file, but changes were actually written successfully. This causes the agent to believe the operation failed and attempt alternative approaches (e.g. strReplace), resulting in duplicate or conflicting edits. The agent ends up modifying already-modified content, potentially causing further corruption.
Note: semanticRename and getDiagnostics (which use LSP/JDT) work perfectly on the same file.
Steps to Reproduce
- Open a large Java file (~390 lines) with many imports (~45), Lombok annotations (@slf4j, @requiredargsconstructor), and Spring annotations (@value, @OverRide)
- Ask the agent to use editCode with insert_node operation to add a method
- Try any selector format - all fail with empty selectors list
- All return:
Error: Could not find target: XXX. Available selectors:(empty list) - Try delete_node - reports success but deletes entire class body
- Try insert_node - reports "Write verification failed" but file is actually modified
- Agent retries with strReplace, causing duplicate edits
Expected Behavior
- AST parser should correctly parse the Java file and find all class/method selectors
- insert_node should insert the method without corrupting the file
- delete_node should only delete the targeted method, not the entire class body
- Write verification should accurately reflect whether changes were applied
For reference, semanticRename and getDiagnostics (which use LSP/JDT Language Server) work perfectly on the same file.
Conversation ID
No response
Additional Context
Environment details:
- Kiro 0.11.63 (user setup), VSCode 1.107.1
- OS: Windows_NT x64 10.0.19045
- Electron: 39.6.0, Node.js: 22.22.0
- Java 11, Spring Boot 2.6.3, Gradle multi-project
File characteristics:
- ~390 lines, ~45 import statements
- Lombok: @slf4j, @service, @requiredargsconstructor
- Spring: @value, @OverRide
- Uses generics, CompletableFuture, Stream API
Workaround: Use strReplace instead of editCode for Java files.
Suggestion: Consider leveraging LSP (JDT Language Server) for AST operations on Java files, similar to how semanticRename and getDiagnostics already use LSP successfully.