Skip to content

edit tool rejects empty string newText as 'Missing required parameter' #19085

@haru217

Description

@haru217

Bug Description

The edit tool's parameter validation treats empty string "" and whitespace-only strings (e.g., "\n") as missing parameters, returning:

Missing required parameter: newText (newText or new_string)

This happens even though the model correctly sends newText in the tool call arguments. The validation appears to use a falsy check (if (!newText)) instead of a proper null/undefined check (=== undefined || === null).

Reproduction

When the model (tested with openai-codex/gpt-5.2) sends an edit tool call to delete a line:

{
  "path": "some/file.kt",
  "oldText": "import kotlinx.serialization.json.Json\n",
  "newText": ""
}

Gateway returns error: Missing required parameter: newText (newText or new_string)

Similarly fails with newText: "\n".

However, a non-empty replacement like newText: "// removed\n" succeeds.

Evidence

From session logs, 6 consecutive failures all with the same pattern:

newText value Result
"" (empty string) Error - Missing required parameter
"" (empty string) Error - Missing required parameter
"" (empty string) Error - Missing required parameter
"" (empty string) Error - Missing required parameter
"\n" (newline only) Error - Missing required parameter
"// import ... (unused)\n" Success

Expected Behavior

newText: "" should be a valid value, as it represents deletion of the matched oldText content (a common edit operation).

Environment

  • OpenClaw version: 2026.2.13 (npm installed)
  • Config version: 2026.2.12
  • Model: openai-codex/gpt-5.2
  • Platform: Windows 11
  • Gateway mode: local

Suggested Fix

In the edit tool parameter validation, change from falsy check to explicit null/undefined check:

- if (!newText) {
+ if (newText === undefined || newText === null) {
    throw new Error('Missing required parameter: newText (newText or new_string)');
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions