- Notifications
You must be signed in to change notification settings - Fork1.2k
Description
Theget_file_contents
tool does not return the SHA hash of the file, which is essential for updating files usingcreate_or_update_file
.
Description
When calling thegithub.get_file_contents
tool, the response object does not include thesha
field for the requested file. The official GitHub REST API documentation for theGET /repos/{owner}/{repo}/contents/{path}
endpoint confirms that thesha
is expected in the response.
This omission prevents the direct use of thegithub.create_or_update_file
tool, as it requires the blob's SHA for any update operation.
Expected Behavior
The response fromget_file_contents
should include the file's SHA hash, consistent with the GitHub API.
{"type":"file","encoding":"base64","size":5362,"name":"file.txt","path":"path/to/file.txt","content":"...","sha":"b23e37d327d520337de2f7a1a4a4b49435b37699" }
Current Behavior
Thesha
field is missing from the tool's response.
Workaround
A functional workaround has been identified:
- Delete the target file using
github.delete_file
(which does not require a SHA). - Recreate the file at the same path using
github.create_or_update_file
with the updated content. This is treated as a new file creation, thus not requiring a SHA.
While effective, this workaround is suboptimal.
Suspected Cause
The server-side implementation of theget_file_contents
tool likely fails to parse or include thesha
field from the GitHub API response before sending it to the client agent.