Bug Description
The fetchGitLabContributions() function in the contributions API route
has no page limit cap. If GitLab returns a malformed x-next-page header
or the same page number repeatedly (due to a proxy or GitLab bug), the
while loop runs forever — hanging the server request indefinitely.
Steps to Reproduce
- Connect a GitLab account
- Simulate a malformed
x-next-page response header from GitLab
- Hit
/api/metrics/contributions
- Observe: request hangs indefinitely, never resolves
Expected Behavior
The fetch should stop after a reasonable number of pages and return
whatever data was collected so far — exactly like the GitHub fetch
already does with its while (page <= 10) cap.
Root Cause
In fetchGitLabContributions() inside
src/app/api/metrics/contributions/route.ts, the while loop condition
is only while (page > 0) with no upper bound. The GitHub fetch in
the same file correctly uses while (page <= 10) as a safety cap —
the GitLab fetch is missing this protection.
Fix
Add a MAX_PAGES = 10 constant and update the loop condition:
const MAX_PAGES = 10;
while (page > 0 && page <= MAX_PAGES) {
File Affected
src/app/api/metrics/contributions/route.ts — fetchGitLabContributions()
Bug Description
The
fetchGitLabContributions()function in the contributions API routehas no page limit cap. If GitLab returns a malformed
x-next-pageheaderor the same page number repeatedly (due to a proxy or GitLab bug), the
while loop runs forever — hanging the server request indefinitely.
Steps to Reproduce
x-next-pageresponse header from GitLab/api/metrics/contributionsExpected Behavior
The fetch should stop after a reasonable number of pages and return
whatever data was collected so far — exactly like the GitHub fetch
already does with its
while (page <= 10)cap.Root Cause
In
fetchGitLabContributions()insidesrc/app/api/metrics/contributions/route.ts, the while loop conditionis only
while (page > 0)with no upper bound. The GitHub fetch inthe same file correctly uses
while (page <= 10)as a safety cap —the GitLab fetch is missing this protection.
Fix
Add a
MAX_PAGES = 10constant and update the loop condition:File Affected
src/app/api/metrics/contributions/route.ts—fetchGitLabContributions()