Skip to content

fix: stop paging a file's history once its commit is found - #3712

Open
kushuh wants to merge 1 commit into
integrations:mainfrom
kushuh:fix/repository-file-commit-paging
Open

kushuh wants to merge 1 commit into
integrations:mainfrom
kushuh:fix/repository-file-commit-paging

Conversation

@kushuh

@kushuh kushuh commented Nov 1, 2026

Copy link
Copy Markdown

Resolves #3711


Before the change?

  • getFileCommit listed every commit that touched the file (GET /repos/{owner}/{repo}/commits?sha={ref}&path={file}, 30 per page, all pages) before checking any of them. Each read of the github_repository_file data source, and each read of the resource that does not know its commit_sha yet, cost one request per 30 commits of the file's history.

After the change?

  • It checks each page as it arrives and returns at the first non-merge commit that changed the file without removing it, which is the same commit as before. A read now costs the contents request, one page of commits and the commit read, however long the history.
  • The commit's file pagination moves, unchanged, into getCommitWithFiles.
  • Measured on a real repository with a read-only token, reading 20 workflow files: v6.13.0 spent 109 requests and this build 54, with identical content, commit_sha, commit_author, commit_email and commit_message for every file.

Pull request checklist

  • Schema migrations have been created if needed (none: the schema does not change)
  • Tests for the changes have been added (for bug fixes / features): Test_getFileCommit asserts the commit returned and the exact requests made. On the current code it fails on the extra page request alone.
  • Docs have been reviewed and added / updated if needed (for bug fixes / features): no documented behavior changes.

Does this introduce a breaking change?

Please see our docs on breaking changes to help!

  • Yes
  • No

This change is largely AI-generated, written with Claude Code. make test and golangci-lint (standard and the strict rules on new code) pass locally.

getFileCommit listed every commit that touched the file before checking
any of them, so each read of a github_repository_file cost one request
per 30 commits of the file's history. It now checks each page as it
arrives and returns at the first match, with the same result.

Fixes integrations#3711

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

👋 Hi, and thank you for this contribution!

This repo is maintained by GitHub and community members on a best-effort basis. We'll get to this as soon as we can.

You can help us prioritize by joining the discussion on open issues and PRs, sharing details on the changes you need, and reviewing other contributions.


🤖 This is an automated message.

@github-actions github-actions Bot added the Type: Bug Something isn't working as documented label Nov 1, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Something isn't working as documented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: data.github_repository_file pages through the file's whole commit history on every read

1 participant