Skip to content

fix(github): Fall back to git blobs API for large files in GetFileContent#6401

Merged
jamengual merged 5 commits into
runatlantis:mainfrom
jayceebernardino:fix/github-1MB-filesize
Apr 21, 2026
Merged

fix(github): Fall back to git blobs API for large files in GetFileContent#6401
jamengual merged 5 commits into
runatlantis:mainfrom
jayceebernardino:fix/github-1MB-filesize

Conversation

@jayceebernardino
Copy link
Copy Markdown
Contributor

what

  • GetFileContent on the GitHub client now falls back to the Git Blobs API when a file exceeds GitHub's 1MB Contents API limit
  • Affects the skip-clone-no-changes feature, which uses GetFileContent to fetch atlantis.yaml before deciding whether to clone

why

  • GitHub's GET /repos/{owner}/{repo}/contents/{path} API returns an empty content field for files larger than 1MB, causing skip-clone-no-changes to fail with a base64 decode error
  • The Git Blobs API (GET /repos/{owner}/{repo}/git/blobs/{sha}) has no size limit and returns the same base64-encoded content — the SHA needed to call it is already present in the Contents API response

tests

  • Added TestClient_GetFileContent with three cases: normal file, file not found, and file over 1MB triggering the blobs fallback

references

Copilot AI review requested due to automatic review settings April 17, 2026 16:46
@dosubot dosubot Bot added go Pull requests that update Go code provider/github labels Apr 17, 2026
Copy link
Copy Markdown
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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a fallback in GetFileContent to use the Git Blobs API when the GitHub Contents API omits content for files over 1MB, preventing base64 decode failures and unblocking skip-clone-no-changes.

Changes:

  • Add Contents API → Blobs API fallback when the Contents response has empty/missing content.
  • Add unit tests covering normal file, not found, and large-file fallback behavior.

Reviewed changes

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

File Description
server/events/vcs/github/client.go Implements Blobs API fallback when Contents API returns empty content for large files.
server/events/vcs/github/client_test.go Adds tests validating normal, not-found, and large-file fallback behavior.

Comment thread server/events/vcs/github/client.go Outdated
Comment thread server/events/vcs/github/client.go Outdated
Comment thread server/events/vcs/github/client_test.go
Comment thread server/events/vcs/github/client_test.go
Comment thread server/events/vcs/github/client_test.go
Comment thread server/events/vcs/github/client_test.go
Comment thread server/events/vcs/github/client_test.go
Comment thread server/events/vcs/github/client_test.go
@jayceebernardino jayceebernardino changed the title Fall back to git blobs API for large files in GetFileContent fix(github): Fall back to git blobs API for large files in GetFileContent Apr 17, 2026
@jayceebernardino jayceebernardino force-pushed the fix/github-1MB-filesize branch from 0bab2e4 to 64b1dad Compare April 17, 2026 16:59
@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Apr 19, 2026
@jayceebernardino jayceebernardino force-pushed the fix/github-1MB-filesize branch from 64b1dad to 009591b Compare April 20, 2026 12:55
…tent

Signed-off-by: Jaycee Hua <jbernardino@moveworks.ai>
@jayceebernardino jayceebernardino force-pushed the fix/github-1MB-filesize branch from 009591b to 09da15d Compare April 20, 2026 13:00
@jamengual jamengual enabled auto-merge (squash) April 21, 2026 04:57
@jamengual jamengual merged commit 6271ee9 into runatlantis:main Apr 21, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update Go code lgtm This PR has been approved by a maintainer provider/github

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants