← Back to PRs

#19125: fix(edit): allow empty string newText for line deletion

by aldoeliacim open 2026-02-17 12:02 View on GitHub →
agents size: XS trusted-contributor
## Summary Fixes #19085 — the edit tool rejects empty string `newText` as a missing required parameter, preventing line deletion via `newText: ""`. ## Root Cause The `assertRequiredParams` validation uses `value.trim().length > 0` for the newText parameter group, which treats empty strings and whitespace-only strings as missing. The `allowEmpty` guard exists but wasn't set for newText. ## Fix Add `allowEmpty: true` to the newText/new_string parameter group in `CLAUDE_PARAM_GROUPS.edit`. This is the same pattern used elsewhere (e.g., in common.ts line 190). ## Changes - `src/agents/pi-tools.read.ts`: Add `allowEmpty: true` to newText param group - `src/agents/pi-tools.read.edit-empty-newtext.test.ts`: 4 unit tests covering empty string, whitespace, missing newText, and missing oldText ## Testing - [x] All 4 new tests pass - [x] `pnpm build` succeeds - [x] Lint passes (0 warnings, 0 errors) AI-assisted (Claude/HAL). Fully tested locally. <!-- greptile_comment --> <h3>Greptile Summary</h3> Fixed validation to allow empty string `newText` in the edit tool for line deletion. Previously, `assertRequiredParams` rejected empty strings using `value.trim().length > 0`, preventing deletion via `newText: ""`. Added `allowEmpty: true` to the newText parameter group, matching the pattern used elsewhere in the codebase (e.g., `src/agents/tools/common.ts:190`). - Added `allowEmpty: true` to newText parameter validation in `CLAUDE_PARAM_GROUPS.edit` - Added comprehensive test coverage with 4 unit tests covering empty strings, whitespace, and missing parameter validation <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk - The fix is minimal, well-targeted, and follows existing patterns. It adds a single boolean flag to enable empty strings for a specific use case. The change is covered by comprehensive unit tests that verify both the new behavior (allowing empty strings) and the existing behavior (rejecting missing parameters). The implementation matches the same pattern used elsewhere in the codebase for similar validation scenarios. - No files require special attention <sub>Last reviewed commit: e52c834</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs