Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Failed to fetch repositories: ${response.statusText} What it means
validateGitlabProvider queries the GitLab projects API with the stored Bearer token and wraps any non-2xx response in a BAD_REQUEST tRPC error. The message carries only statusText, so the underlying cause (auth, permissions, group path) is hidden.
Source
Thrown at packages/server/src/utils/providers/gitlab.ts:318
const allProjects = [];
let page = 1;
const perPage = 100; // GitLab's max per page is 100
const baseUrl = (
gitlabProvider.gitlabInternalUrl || gitlabProvider.gitlabUrl
).replace(/\/+$/, "");
while (true) {
const response = await fetch(
`${baseUrl}/api/v4/projects?membership=true&page=${page}&per_page=${perPage}`,
{
headers: {
Authorization: `Bearer ${gitlabProvider.accessToken}`,
},
},
);
if (!response.ok) {
throw new TRPCError({
code: "BAD_REQUEST",
message: `Failed to fetch repositories: ${response.statusText}`,
});
}
const projects = await response.json();
if (projects.length === 0) {
break;
}
allProjects.push(...projects);
page++;
const total = response.headers.get("x-total");
if (total && allProjects.length >= Number.parseInt(total)) {
break;
}View on GitHub (pinned to 546686ea35)
Solutions
- Verify groupName is the exact group path (URL-encoded if it contains spaces/slashes)
- Refresh the token / re-authorize the provider and retry
- Check the OAuth scopes include api or read_api
- Inspect response.status and body for 401/403/404/429 to pinpoint the cause
Example fix
// before
if (!response.ok) {
throw new TRPCError({ code: "BAD_REQUEST", message: `Failed to fetch repositories: ${response.statusText}` });
}
// after
if (!response.ok) {
const body = await response.text();
throw new TRPCError({ code: "BAD_REQUEST", message: `Failed to fetch repositories: ${response.status} ${body}` });
} Defensive patterns
Strategy: try-catch
Validate before calling
const encoded = encodeURIComponent(groupName.trim());
Try / catch
try {
const repos = await validateGitlabProvider(...);
} catch (e) {
if (e instanceof TRPCError && e.code === 'BAD_REQUEST') {
// surface message, suggest re-auth for 401-type causes
}
throw e;
} Prevention
- Refresh token before validation calls
- Verify group membership and exact group path before saving the provider
When it happens
Trigger: Expired access token, token without read_api scope, groupName that doesn't exist or the user isn't a member of, or a GitLab instance that is unreachable/rate-limiting (429).
Common situations: Adding a GitLab provider for a group the token can't see; self-hosted GitLab behind a proxy returning 502; rate limits when scanning large groups.
Understand the failure class
Background: BAD_REQUEST error code: request rejected as invalid (HTTP 400) - causes and fixes across libraries — this error's family across 8 libraries.
Related errors
- BAD_REQUEST
- Failed to refresh token: ${response.statusText}
- Failed to fetch branches: ${branchesResponse.statusText}
- INNGEST_BASE_URL is required to list deployment jobs
- UNAUTHORIZED
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/e932508a8292b48e.
Report an issue: GitHub.