Skip to content

Commit 29c93e6

Browse files
perf(bitbucket): increase server page limit to 1000 (#981)
* perf(bitbucket): increase server page limit to 1000 for fetching all repos Requests 1000 repos per page instead of defaulting to 25, reducing the number of API calls needed to enumerate large Bitbucket Server instances. The server silently caps at its configured maximum (page.max.repositories), so pagination via isLastPage/nextPageStart remains correct regardless. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * perf(bitbucket): bump remaining getPaginatedServer call sites to limit 1000 Updates serverGetReposForProjects, getReposForAuthenticatedBitbucketServerUser, and getUserPermissionsForServerRepo to match the limit set in serverGetAllRepos. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * docs * changelog --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent f72ce47 commit 29c93e6

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
- Increased pagination limit to 1000 for bitbucket data center requests. [#981](https://github.com/sourcebot-dev/sourcebot/pull/981)
12+
1013
## [4.15.0] - 2026-03-05
1114
- Added MCP and API key usage tracking to analytics dashboard and added audit retention system [#950](https://github.com/sourcebot-dev/sourcebot/pull/950)
1215

docs/docs/connections/bitbucket-data-center.mdx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,23 @@ In order to index private repositories, you'll need to provide a [HTTP Access To
150150
</Tab>
151151
</Tabs>
152152

153+
## Rate limiting
154+
155+
Bitbucket Data Center supports [rate limiting](https://confluence.atlassian.com/bitbucketserver094/improving-instance-stability-with-rate-limiting-1489803023.html) to protect instance stability. Rate limiting applies to HTTP requests with basic or bearer authentication, which includes the REST API calls Sourcebot makes to sync repositories.
156+
157+
If rate limiting is enabled on your instance, Sourcebot may receive `HTTP 429 (Too Many Requests)` errors during sync. To prevent this, add a rate limiting exemption for the user (service account) whose token is used in your connection config.
158+
159+
To add an exemption:
160+
161+
1. In Bitbucket Data Center, go to **Administration****Rate limiting****Exemptions** tab.
162+
2. Click **Add exemption** and find the service account user.
163+
3. Select **Allow unlimited requests** (recommended) or set a custom token bucket size and refill rate appropriate for your sync volume.
164+
4. Click **Save**.
165+
166+
<Frame>
167+
<img src="/images/bitbucket_rate_limit.png" alt="Bitbucket Data Center rate limiting exemptions tab showing a user with unlimited requests" />
168+
</Frame>
169+
153170
## Troubleshooting
154171
If you're seeing errors like `TypeError: fetch failed` when fetching repo info, it may be that Sourcebot is refusing to connect to your self-hosted Bitbucket instance due to unrecognized SSL certs. Try setting the `NODE_TLS_REJECT_UNAUTHORIZED=0` environment variable or providing Sourcebot your certs through the `NODE_EXTRA_CA_CERTS` environment variable.
155172

130 KB
Loading

packages/backend/src/bitbucket.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ async function serverGetReposForProjects(client: BitbucketClient, projects: stri
480480
const response = await client.apiClient.GET(url, {
481481
params: {
482482
query: {
483+
limit: 1000,
483484
start,
484485
}
485486
}
@@ -581,7 +582,7 @@ async function serverGetAllRepos(client: BitbucketClient): Promise<{repos: Serve
581582
const { durationMs, data } = await measure(async () => {
582583
const fetchFn = () => getPaginatedServer<ServerRepository>(path, async (url, start) => {
583584
const response = await client.apiClient.GET(url, {
584-
params: { query: { start } }
585+
params: { query: { limit: 1000, start } }
585586
});
586587
const { data, error } = response;
587588
if (error) {
@@ -712,7 +713,7 @@ export const getReposForAuthenticatedBitbucketServerUser = async (
712713
params: {
713714
query: {
714715
permission: 'REPO_READ',
715-
limit: 100,
716+
limit: 1000,
716717
start,
717718
},
718719
},
@@ -747,7 +748,7 @@ export const getUserPermissionsForServerRepo = async (
747748
`/rest/api/1.0/projects/${projectKey}/repos/${repoSlug}/permissions/users` as ServerGetRequestPath,
748749
async (url, start) => {
749750
const response = await client.apiClient.GET(url, {
750-
params: { query: { limit: 100, start } },
751+
params: { query: { limit: 1000, start } },
751752
});
752753
const { data, error } = response;
753754
if (error) {

0 commit comments

Comments
 (0)