Skip to content

fix: reject malformed write payloads before changing files - #2028

Merged
santoshkumarradha merged 1 commit into
devfrom
fix/validate-write-text
Oct 29, 2026
Merged

santoshkumarradha merged 1 commit into
devfrom
fix/validate-write-text

Conversation

@santoshkumarradha

@santoshkumarradha santoshkumarradha commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Malformed write calls could create empty files or truncate existing files because missing/null payloads decoded as empty strings. Validate the required payload before filesystem work across compact workers (text), chat writes (content), and appends. Explicit empty strings remain valid.

 write(path, payload)
+  require payload to be a string
   create parent directories
   write bytes

Evidence

  • Before: regression tests reproduced empty-file creation and loss of existing bytes. An installed-binary replay also reproduced a malformed write reporting success with zero bytes.
    After: regressions reject missing/null/non-string payloads before mutation, preserve existing files, and avoid creating parent directories. Valid content and intentional empty writes pass.
  • make build and make pr-ready passed, including fresh tests for the changed execution and session packages. Independent standards and requirements reviews found no blocking issues.
  • Live verification on 27615d9fb8a4: 3/3 passed, using OpenRouter deepseek/deepseek-v4.1-flash for every model call: compact exec, normal chat --once, and chat append. The test deliberately renamed the first write's required field to reproduce the malformed argument. Each path returned an actionable tool error with no filesystem mutation; the real model then corrected its arguments and completed the valid write. This is controlled fault injection with a live model, not a claim that the model spontaneously generated the malformed call.

Merge Danger

Door: two-way

Blast Radius: write

Valid tool schemas and successful-write outputs are unchanged. Malformed calls now return an error for the model to correct.

@santoshkumarradha
santoshkumarradha merged commit 66fa77e into dev Oct 29, 2026
6 checks passed
@santoshkumarradha
santoshkumarradha deleted the fix/validate-write-text branch October 29, 2026 11:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant