Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
err instanceof Error ? err?.message : `Error: ${err}` What it means
The github.testGithubProvider procedure chains findGithubById, a permission assertion (assertGitProviderAccess), and getGithubRepositories; any failure in that chain is wrapped with the original message preserved. Most commonly it is an auth failure against the GitHub API or a permission denial from the session check.
Source
Thrown at apps/dokploy/server/api/routers/github.ts:89
gitProvider: {
...provider.gitProvider,
},
};
});
return filtered;
}),
testConnection: protectedProcedure
.input(apiFindOneGithub)
.mutation(async ({ input, ctx }) => {
try {
const github = await findGithubById(input.githubId);
await assertGitProviderAccess(ctx.session, github.gitProvider);
const result = await getGithubRepositories(input.githubId);
return `Found ${result.length} repositories`;
} catch (err) {
throw new TRPCError({
code: "BAD_REQUEST",
message: err instanceof Error ? err?.message : `Error: ${err}`,
});
}
}),
update: withPermission("gitProviders", "create")
.input(apiUpdateGithub)
.mutation(async ({ input, ctx }) => {
await updateGitProvider(input.gitProviderId, {
name: input.name,
organizationId: ctx.session.activeOrganizationId,
});
await updateGithub(input.githubId, {
...input,
});
await audit(ctx, {View on GitHub (pinned to 546686ea35)
Solutions
- Check whether the message is a permission denial — if so switch back to the organization that owns the provider or grant access
- If 401/Bad credentials, reconnect the GitHub provider with a fresh token
- If rate-limited, wait and retry; check X-RateLimit headers in server logs
- Verify network egress to api.github.com
Defensive patterns
Strategy: try-catch
Try / catch
try { await api.github.testGithubProvider.query({ githubId }); } catch (e) { if (/permission|access/i.test((e as Error).message)) switchOrg(); else reconnectProvider(); } Prevention
- Re-test provider connections after org switches
- Monitor token expiry for GitHub Apps
When it happens
Trigger: Expired/revoked GitHub access token; the session's user lacks access to the git provider's owning organization (assertGitProviderAccess throws); GitHub API rate-limit or network failure from the server.
Common situations: GitHub App / OAuth token expired after rotation; user switched active organization so the provider is no longer accessible; server IP rate-limited by GitHub API.
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
AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27).
Data as JSON: /api/errors/64498cca22768c10.
Report an issue: GitHub.