Repository navigation
fix(repos): allow explicitly empty file content - #3884
Open
Elon-Jiang wants to merge 1 commit into
Open
Elon-Jiang wants to merge 1 commit into
Elon-Jiang wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues block the change enabling intentionally empty file writes.
No open issues 🎉
What changed in this PR
Fixes #3883 by allowing create_or_update_file to create empty files or intentionally clear existing files without changing its public input type or schema.
Changes:
- Accepts explicit
content: ""while continuing to reject missing or null content. - Adds regression cases for empty creation, clearing existing files, and missing/null content.
- Documents empty writes and the current-SHA requirement for clearing existing files.
| File | Description |
|---|---|
pkg/skills/catalog/skills/repository-content-changes/SKILL.md |
Documents intentionally empty writes. |
pkg/github/repositories.go |
Distinguishes explicit empty content from missing or null values. |
pkg/github/repositories_test.go |
Adds empty-write and missing/null regression cases. |
Review effort: Balanced (adaptive)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allow
create_or_update_fileto create empty files and intentionally clear existing files whencontent: ""is explicitly supplied.Why
Fixes #3883. Agents cannot currently create empty package markers (
__init__.py,.gitkeep) or clear a file: an empty string is treated as a missing parameter before any request reaches GitHub. The Contents API accepts base64 file content, and the tool schema does not impose a minimum length.What changed
MCP impact
Prompts tested (tool changes only)
The tests invoke tool arguments directly; no LLM prompt execution is claimed. The corresponding use cases are “create an empty package marker on this branch” and “clear this ordinary file using its current blob SHA.” The HTTP transport substitutes GitHub's service; the public tool handler, validation and REST serialization run normally. No live account file write was used in testing.
Security / limits
Tool renaming
Lint & tests
./script/lint(Go 1.27.3, pinned golangci-lint 2.14.0): passed../script/test(go test -race ./...): passed.UPDATE_TOOLSNAPS=true go test ./...: passed; no snapshot changes.Baseline: the two empty-write cases fail; 15 existing controls pass. After the fix, all 19 cases pass, including the two new absent/null controls.
Docs
./script/generate-docspassed without README changes.Skills
Prepared with AI assistance. No claim of independent human review is made.