Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Error creating this Bitbucket provider
What it means
This TRPCError (BAD_REQUEST) is a catch-all wrapper thrown when the underlying createBitbucketProvider service call fails while creating a Bitbucket git provider in Dokploy. The original error is attached via `cause`, so the real reason (bad credentials, duplicate name, DB constraint) is nested inside. It is not a Bitbucket API error per se — any failure inside the try block is masked by this generic message.
Source
Thrown at apps/dokploy/server/api/routers/bitbucket.ts:46
create: withPermission("gitProviders", "create")
.input(apiCreateBitbucket)
.mutation(async ({ input, ctx }) => {
try {
const result = await createBitbucket(
input,
ctx.session.activeOrganizationId,
ctx.session.userId,
);
await audit(ctx, {
action: "create",
resourceType: "gitProvider",
resourceName: input.name,
});
return result;
} catch (error) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error creating this Bitbucket provider",
cause: error,
});
}
}),
one: protectedProcedure
.input(apiFindOneBitbucket)
.query(async ({ input, ctx }) => {
const bitbucket = await findBitbucketById(input.bitbucketId);
await assertGitProviderAccess(ctx.session, bitbucket.gitProvider);
return bitbucket;
}),
bitbucketProviders: protectedProcedure.query(async ({ ctx }) => {
const accessibleIds = await getAccessibleGitProviderIds(ctx.session);
let result = await db.query.bitbucket.findMany({
with: {View on GitHub (pinned to 546686ea35)
Solutions
- Inspect the TRPC error's `cause` on the client/server log to find the real underlying message
- Verify the Bitbucket provider input: name uniqueness, workspace slug, username and credentials format
- Retry after fixing credentials; confirm the DB is reachable and the `git_provider` table has no constraint violations
- If the cause is a Bitbucket API 401/403, reissue the app password/OAuth client and try again
Example fix
// before
await trpc.bitbucket.create.mutate({ name: 'my-repo', ... });
// Error: Error creating this Bitbucket provider
// after — surface the underlying cause
try {
await trpc.bitbucket.create.mutate({ name: 'my-repo', ... });
} catch (e) {
const cause = e?.cause ?? e;
console.error('bitbucket.create failed:', cause?.message ?? cause);
throw cause;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate input shape before calling
if (!input?.name || !input?.bitbucketUsername || !input?.workspace) {
throw new Error('Missing required Bitbucket provider fields');
} Type guard
function isValidBitbucketInput(i: unknown): i is { name: string; workspace: string; bitbucketUsername: string } {
return typeof i === 'object' && i !== null
&& typeof (i as any).name === 'string' && (i as any).name.length > 0
&& typeof (i as any).workspace === 'string'
&& typeof (i as any).bitbucketUsername === 'string';
} Try / catch
try {
await trpc.bitbucket.create.mutate(input);
} catch (e: any) {
const cause = e?.cause ?? e;
if (/duplicate key|unique/i.test(cause?.message ?? '')) throw new Error('Provider name already exists');
if (/401|credentials/i.test(cause?.message ?? '')) throw new Error('Invalid Bitbucket credentials');
throw cause;
} Prevention
- Always name providers uniquely per organization
- Test credentials with bitbucket.testConnection before automating
- Log the TRPC cause, not just the top-level message
When it happens
Trigger: Calling the `bitbucket.create` mutation with malformed credentials (wrong workspace/repo-slug format), a duplicate provider name, an invalid bitbucketUsername, or when the database insert fails. Inspect `error.cause` for the actual driver error.
Common situations: OAuth app credentials misconfigured, pasting a workspace UUID instead of the slug, creating a second provider with the same name, or a transient DB outage during creation.
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/7744b8ef66dde912.
Report an issue: GitHub.