Repository navigation
picod: allow empty file content in JSON upload - #481
Conversation
UploadFileRequest.Content used binding:required on a string, which rejects an empty string, so an empty file could not be created via JSON upload (the base64 of an empty file is an empty string). Make Content a *string so an empty value is accepted while a missing field is still rejected. Signed-off-by: Anirudh <anirudhpatwal19@gmail.com>
b54a9d1 to
828fb12
Compare
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: acsoto The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #481 +/- ##
==========================================
+ Coverage 59.98% 60.42% +0.43%
==========================================
Files 36 35 -1
Lines 3589 3618 +29
==========================================
+ Hits 2153 2186 +33
+ Misses 1216 1212 -4
Partials 220 220
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
What type of PR is this?
/kind bug
What this PR does / why we need it
UploadFileRequest.Contenthadbinding:"required"on a plain string. Gin treats an empty string as missing, so a JSON upload with"content": ""was rejected with a 400. Since the base64 of an empty file is an empty string, there was no way to create an empty file this way. That breakswrite_file("", ...)in the Python SDK,run_codewith empty code, and the MCP server'swrite_filetool. Multipart upload of the same empty file already worked.This changes
Contentto*stringand keepsbinding:"required", so:"content": ""creates a zero-byte filecontentfield is still rejected with 400Which issue(s) this PR fixes
Fixes #476
Special notes for your reviewer
Added
TestHandleJSONBase64Upload_Content, which covers empty content, missing content and normal content. The empty-content case fails onmainand passes with this change. I also checked it end to end with the Python SDK against a local PicoD build:write_file("", "pkg/__init__.py")returned 400 before and succeeds now.Does this PR introduce a user-facing change?