From 1eae832e64e1088e0a46a21521233f64a06891cd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 12 May 2026 23:58:06 +0000 Subject: [PATCH 1/2] Initial plan From 25da44ef5649669efb200cba6594364fa8c3107a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 13 May 2026 00:03:19 +0000 Subject: [PATCH 2/2] Handle Octokit::Forbidden for large contributor lists with warning and empty return Agent-Logs-Url: https://github.com/jekyll/github-metadata/sessions/998e9980-bf0f-4a9b-b759-5a9dcaaf5631 Co-authored-by: parkr <237985+parkr@users.noreply.github.com> --- lib/jekyll-github-metadata/client.rb | 3 +++ spec/client_spec.rb | 17 +++++++++++++++++ .../webmock/api_get_contributors_forbidden.json | 4 ++++ 3 files changed, 24 insertions(+) create mode 100644 spec/webmock/api_get_contributors_forbidden.json diff --git a/lib/jekyll-github-metadata/client.rb b/lib/jekyll-github-metadata/client.rb index aab378b..29c882e 100644 --- a/lib/jekyll-github-metadata/client.rb +++ b/lib/jekyll-github-metadata/client.rb @@ -95,6 +95,9 @@ def save_from_errors(default = false) rescue Faraday::ConnectionFailed, Octokit::TooManyRequests => e GitHubMetadata.log :warn, e.message default + rescue Octokit::Forbidden => e + GitHubMetadata.log :warn, "#{e.message} This is a limitation of the GitHub API." + default rescue Octokit::NotFound default end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 7ab97f2..c05c31f 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -39,6 +39,23 @@ end.to raise_error(described_class::BadCredentialsError) end + it "warns and returns false when contributors list is too large" do + stub_request(:get, url("/repos/jekyll/github-metadata/contributors?per_page=100")) + .with(:headers => request_headers.merge( + "Authorization" => "token #{token}" + )) + .to_return( + :status => 403, + :headers => WebMockHelper::RESPONSE_HEADERS, + :body => webmock_data("contributors_forbidden") + ) + logger_output = StringIO.new + Jekyll::GitHubMetadata.logger = Logger.new(logger_output) + result = subject.contributors("jekyll/github-metadata") + expect(result).to be(false) + expect(logger_output.string).to include("This is a limitation of the GitHub API") + end + it "supresses network accesses if requested" do WebMock.disable_net_connect! diff --git a/spec/webmock/api_get_contributors_forbidden.json b/spec/webmock/api_get_contributors_forbidden.json new file mode 100644 index 0000000..3f89d7a --- /dev/null +++ b/spec/webmock/api_get_contributors_forbidden.json @@ -0,0 +1,4 @@ +{ + "message": "The history or contributor list is too large to list contributors for this repository via the API.", + "documentation_url": "https://docs.github.com/rest/repos/repos#list-repository-contributors" +}