Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix: Specify sha is required for file update#320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

crondinini
Copy link
Contributor

Closes:#191

The problem

When the LLM sends anupdate_file request, it doesn't include thesha of the file being replaced, leading to the error:

Failed to call tool create_or_update_file: Error: MCP error -32603: failed to https://api.github.com/repos/evanmcgillivray/Budget/contents/src/components422 Invalid request. "sha" wasn't supplied. []

This happens becausesha is an optional field since the same tool is used for bothcreate andupdate file operations.

The solution

I did some local testing and the issue seems to be fixed if we specify in the tool description thatsha is required when updating a file.

However, a more robust solution might be to split the tool into 2 separate tools and and make a newupdate_file tool that has a requiredsha property.

I wasn't sure which approach would be preferred, so I've decided to put forward the simplest solution that works to hear your feedback.

SamMorrowDrums reacted with heart emoji
@CopilotCopilotAI review requested due to automatic review settingsApril 21, 2025 08:10
@crondininicrondinini requested a review froma team as acode ownerApril 21, 2025 08:10
Copy link
Contributor

@CopilotCopilotAI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Pull Request Overview

This PR updates the tool description for file operations to indicate that a SHA is required when updating a file.

  • Updated the tool description for create_or_update_file.
  • Clarified that the SHA field must be provided when updating a file.

@@ -216,7 +216,7 @@ func ListBranches(getClient GetClientFn, t translations.TranslationHelperFunc) (
// CreateOrUpdateFile creates a tool to create or update a file in a GitHub repository.
func CreateOrUpdateFile(getClient GetClientFn, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
return mcp.NewTool("create_or_update_file",
mcp.WithDescription(t("TOOL_CREATE_OR_UPDATE_FILE_DESCRIPTION", "Create or update a single file in a GitHub repository")),
mcp.WithDescription(t("TOOL_CREATE_OR_UPDATE_FILE_DESCRIPTION", "Create or update a single file in a GitHub repository. If updating, you must provide the SHA of the file you want to update.")),
Copy link
Preview

CopilotAIApr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The updated tool description indicates that a SHA is required when updating a file, but there is no validation enforcing this constraint. Consider adding a check to ensure that the SHA field is provided when processing an update.

Copilot uses AI. Check for mistakes.

@juruen
Copy link
Collaborator

juruen commentedApr 28, 2025
edited
Loading

However, a more robust solution might be to split the tool into 2 separate tools and and make a newupdate_file tool that has a requiredsha property.

I wasn't sure which approach would be preferred, so I've decided to put forward the simplest solution that works to hear your feedback.

Thank you so much for the PR.

@crondinini Although having separate tools allows us to specify the required field directly in the schema, there have been some concerns about adding too many tools. That’s why we sometimes prefer to merge several tools into one. As far as I know, this isn’t set in stone yet and could definitely change.

Having said that, as this is a minor change to the description that might help to make sure that the update operation is called correctly, I think we should merge it. Please, feel free to correct my assumption!

I've successfully tested it:

Screenshot 2025-04-28 at 11 16 02

Screenshot 2025-04-28 at 11 16 13

juruen
juruen previously approved these changesApr 28, 2025
@crondinini
Copy link
ContributorAuthor

@juruen Thank you for the review and for the explanation. That makes sense. Considering this is such a small change that fixes a bug, I agree it makes sense to merge.

I had to solve a conflict so the review was automatically dismissed.

If you could give your approval again, that would be great! Thank you :)

Copy link
Collaborator

@SamMorrowDrumsSamMorrowDrums left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thank you for this 🙏

crondinini reacted with rocket emoji
@SamMorrowDrumsSamMorrowDrums merged commita7d741c intogithub:mainApr 29, 2025
9 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

Copilot code reviewCopilotCopilot left review comments

@SamMorrowDrumsSamMorrowDrumsSamMorrowDrums approved these changes

@juruenjuruenjuruen left review comments

Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

MCP Error -32603: 422 Invalid request - 'sha' wasn't supplied when updating file
3 participants
@crondinini@juruen@SamMorrowDrums

[8]ページ先頭

©2009-2025 Movatter.jp