create_or_update_file rejects explicitly empty file content
Maintainers usually reply within 4 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- github, go
- Domain
- backend-api-design
Research direction
Start at CreateOrUpdateFile(...).Handler(...) and compare how it handles an explicitly empty content string with push_files; the issue reports two failing regression cases and passing nonempty create/update cases. Add coverage for empty content on create and update, while retaining rejection of absent or null content and the stated SHA and symlink protections. Done when those cases pass through the real go-github client without an early missing-content error.
Written by the indexing model from the issue text.
Description
Description
create_or_update_file rejects an explicitly supplied empty string with missing required parameter: content, preventing agents from creating empty package markers such as __init__.py / .gitkeep, or intentionally clearing an existing file.
The tool schema requires a string but does not impose a minimum length. The GitHub Contents API accepts empty base64 content, and push_files already distinguishes absent content from an explicitly empty string.
Reproduction
Call the tool with {"owner":"owner","repo":"repo","path":"__init__.py","branch":"main","message":"Add package marker","content":""}. Expected: a Contents API request with content: "". Actual: the tool returns an error before making any HTTP request. Updating an existing ordinary file with its current SHA fails in the same way.
Reproduced at 4e6e6c053e48aac182f7768162fef2ad42fe7d5f through CreateOrUpdateFile(...).Handler(...), using the real go-github REST client with a controlled HTTP transport. Two new regression cases fail; existing nonempty create/update cases pass. No live repository write was performed in reproduction.
I plan to allow explicitly empty content while continuing to reject absent/null content, preserving the existing exported Go input type, JSON schema, SHA validation and symlink protections. I checked the complete open PR file lists and relevant closed PRs; #3313 (binary encoding) and #2772 (GraphQL migration) retain the empty-string rejection and address different behavior.
This report and proposed fix were prepared with AI assistance.
- Dominant language
- Go
- Stars
- 34.4k
- Forks
- 5.3k
- Avg merge
- 4d 12h
- Merged PRs (30d)
- 13
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from github/github-mcp-server
-
csv_output silently overwrites distinct fields when flattened keys collidePossibly taken @Mystery01092000 claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
github/github-mcp-server#3865 ·
Maintainers usually reply within 4 days
-
update_issue_labels is annotated destructiveHint: false but replaces (removes) existing labelsPossibly taken @shhhhhhjokerist claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
github/github-mcp-server#3760 · 1 comment ·
Maintainers usually reply within 4 days
-
docs(install-claude): "environment variable" examples put the PAT in argv and the saved configPossibly taken @shhhhhhjokerist claimed this 8 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
github/github-mcp-server#3758 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
github/github-mcp-server#3729 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
github/github-mcp-server#3722 ·
Maintainers usually reply within 4 days
All issues in github/github-mcp-server
Similar issues
-
agent-review-finding chore
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
jordansmall/spindrift#7254 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pg-sharding/spqr#3275 ·
Maintainers usually reply within 1 day
-
feature
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
databricks/terraform-provider-databricks#6210 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
IBM-Cloud/terraform-provider-ibm#7115 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
fluxcd/notification-controller#1441 ·
Maintainers usually reply within 1 day