🌐 AI搜索 & 代理 主页
Skip to content

Conversation

@almaleksia
Copy link
Contributor

This PR contains refactoring of get_file_contents tool that eliminates error file content SHA is nil, if a directory was requested, path parameters should end with a trailing slash '/'

We shouldn't fail when trailing slash is not supplied. Also, for both directories and files the same API call is being used, therefore there's no need for two separate logical paths.

I removed the reliance on trailing slash and branching related to it. Instead, if GetContents returns directory content - we return it, if it is a file - we proceed with downloading etc.

@almaleksia almaleksia requested a review from a team as a code owner December 12, 2025 10:50
Copilot AI review requested due to automatic review settings December 12, 2025 10:50
Copy link
Contributor

Copilot AI 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 refactors the get_file_contents tool to eliminate the requirement for directory paths to end with a trailing slash. The refactoring unifies the code path for both files and directories by first calling the GitHub Contents API to determine the type, then proceeding accordingly.

Key Changes:

  • Removed the trailing slash requirement from the path parameter description
  • Unified the GetContents API call for both files and directories instead of having separate conditional logic
  • Simplified control flow by checking the response type (file vs directory) after the API call rather than before

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
pkg/github/repositories.go Refactored GetFileContents function to remove trailing slash dependency and unify the API call path for files and directories; updated parameter description
pkg/github/toolsnaps/get_file_contents.snap Updated tool schema snapshot to reflect the changed path parameter description

tommaso-moro
tommaso-moro previously approved these changes Dec 12, 2025
Copy link
Contributor

@tommaso-moro tommaso-moro left a comment

Choose a reason for hiding this comment

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

left a comment but otherwise lgtm!

SamMorrowDrums
SamMorrowDrums previously approved these changes Dec 12, 2025
@almaleksia almaleksia force-pushed the almaleksia/get_file_contents_fixes branch from f4a7585 to a3460a9 Compare December 12, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants