From 3e849b943dbc38459b6f3a97876f7466272518f2 Mon Sep 17 00:00:00 2001 From: KayZ Date: Sat, 30 May 2026 17:43:23 -0600 Subject: [PATCH 1/3] Limit API fetch to 100 commits per page --- src/components/contributors.astro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/contributors.astro b/src/components/contributors.astro index 9fb0a012..059c1cce 100644 --- a/src/components/contributors.astro +++ b/src/components/contributors.astro @@ -8,7 +8,7 @@ const { repo, file } = Astro.props; // Build an API URL that gets the 100 most recent commits for the specified file. // See https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits const url = new URL(`https://api.github.com/repos/${repo}/commits`); -url.searchParams.set('per_page', 1000); +url.searchParams.set('per_page', 100); // Fetch commits from the GitHub API const commits = await fetch(url, { From 4e60370d25545562692f35810280a39de15b4b43 Mon Sep 17 00:00:00 2001 From: KayZ Date: Sat, 30 May 2026 17:49:03 -0600 Subject: [PATCH 2/3] Added Error Handling for GH API response for contributors --- src/components/contributors.astro | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/contributors.astro b/src/components/contributors.astro index 059c1cce..9a91f523 100644 --- a/src/components/contributors.astro +++ b/src/components/contributors.astro @@ -19,7 +19,11 @@ const commits = await fetch(url, { }).then((res) => res.json()); function removeDuplicates(commits) { - if (!commits) return []; + if (!Array.isArray(commits)) { + throw new Error( + `GitHub API did not return a commits array. This is likely a rate limit or auth issue; Re-run the build.\nAPI response: ${JSON.stringify(commits)}` + ); + } const map = new Map(); for (const commit of commits) { const author = commit.author; From f4ffd1b00b5e285ff85a1a6f272a6431f283a69d Mon Sep 17 00:00:00 2001 From: KayZ Date: Sat, 30 May 2026 18:00:19 -0600 Subject: [PATCH 3/3] Copilot suggests checking name of repo, sure I guess (also fixed comment cuz copilot be nitpicky) --- src/components/contributors.astro | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/contributors.astro b/src/components/contributors.astro index 9a91f523..6bbecff3 100644 --- a/src/components/contributors.astro +++ b/src/components/contributors.astro @@ -5,7 +5,7 @@ interface Props { } const { repo, file } = Astro.props; -// Build an API URL that gets the 100 most recent commits for the specified file. +// Build an API URL that gets the 100 most recent commits for the overall repo. // See https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#list-commits const url = new URL(`https://api.github.com/repos/${repo}/commits`); url.searchParams.set('per_page', 100); @@ -21,7 +21,7 @@ const commits = await fetch(url, { function removeDuplicates(commits) { if (!Array.isArray(commits)) { throw new Error( - `GitHub API did not return a commits array. This is likely a rate limit or auth issue; Re-run the build.\nAPI response: ${JSON.stringify(commits)}` + `GitHub API did not return a commits array. Check the repo name, authentication, and rate limits.\nAPI response: ${JSON.stringify(commits)}` ); } const map = new Map();