write and edit tools return spurious 'cmd must not be empty' error despite successful operations #1493

Closed
opened 2026-02-16 17:31:14 -05:00 by yindo · 3 comments
Owner

Originally created by @smantzavinos on GitHub (Aug 26, 2025).

Originally assigned to: @thdxr on GitHub.

Environment

  • OS: NixOS
  • Tool: OpenCode CLI (Claude Code)
  • Affected Tools: write and edit
  • Error: TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty

Problem Description

Both write and edit tools consistently return a TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty error message, but the actual file operations succeed correctly. This creates confusion as the error suggests failure when operations actually work.

Reproduction Steps

  1. Use write tool to create a new file
  2. Use edit tool to modify an existing file
  3. Both operations return the error but successfully perform the intended file operations

Expected Behavior

Tools should complete successfully without error messages when operations succeed.

Actual Behavior

  • Operations succeed (files are created/modified correctly)
  • Error message appears: TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty
  • Creates confusion about operation success/failure

Evidence

write tool: Creates file successfully + shows error
edit tool: Modifies file successfully + shows error
File verification: All changes applied correctly

Example Output

> write tool call to create test_file.md
TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty

> read test_file.md
File exists with correct content - operation actually succeeded

Hypothesis

Tools may be internally executing empty commands for validation/verification while the actual file operations use direct filesystem APIs.

Impact

  • Misleading error reporting
  • Confusion about operation success
  • Potential automation issues if error handling relies on tool return codes
Originally created by @smantzavinos on GitHub (Aug 26, 2025). Originally assigned to: @thdxr on GitHub. ## Environment - **OS**: NixOS - **Tool**: OpenCode CLI (Claude Code) - **Affected Tools**: `write` and `edit` - **Error**: `TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty` ## Problem Description Both `write` and `edit` tools consistently return a `TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty` error message, but the actual file operations succeed correctly. This creates confusion as the error suggests failure when operations actually work. ## Reproduction Steps 1. Use `write` tool to create a new file 2. Use `edit` tool to modify an existing file 3. Both operations return the error but successfully perform the intended file operations ## Expected Behavior Tools should complete successfully without error messages when operations succeed. ## Actual Behavior - Operations succeed (files are created/modified correctly) - Error message appears: `TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty` - Creates confusion about operation success/failure ## Evidence ``` write tool: Creates file successfully + shows error edit tool: Modifies file successfully + shows error File verification: All changes applied correctly ``` ## Example Output ``` > write tool call to create test_file.md TypeError [ERR_INVALID_ARG_TYPE]: cmd must not be empty > read test_file.md File exists with correct content - operation actually succeeded ``` ## Hypothesis Tools may be internally executing empty commands for validation/verification while the actual file operations use direct filesystem APIs. ## Impact - Misleading error reporting - Confusion about operation success - Potential automation issues if error handling relies on tool return codes
yindo closed this issue 2026-02-16 17:31:14 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Aug 26, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #1090: Similar issue where edit tool returns error status (126) but file operations actually succeed
  • #1357: Reports constant failures to use Write/Edit tools with various models
  • #1498: AI_InvalidToolInputError with write tool validation failures

The symptoms in #1090 are particularly similar - successful file operations accompanied by spurious error messages. Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Aug 26, 2025): This issue might be a duplicate of existing issues. Please check: - #1090: Similar issue where edit tool returns error status (126) but file operations actually succeed - #1357: Reports constant failures to use Write/Edit tools with various models - #1498: AI_InvalidToolInputError with write tool validation failures The symptoms in #1090 are particularly similar - successful file operations accompanied by spurious error messages. Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Aug 26, 2025):

@smantzavinos does this only happen when working with certain files or is this a constant thing? What kind of project is this?

@rekram1-node commented on GitHub (Aug 26, 2025): @smantzavinos does this only happen when working with certain files or is this a constant thing? What kind of project is this?
Author
Owner

@rekram1-node commented on GitHub (Dec 27, 2025):

[automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!

@rekram1-node commented on GitHub (Dec 27, 2025): [automated] Closing due to 90+ days of inactivity. Feel free to reopen if you still need this!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1493