Dokploy/dokploy · error · TRPCError
BAD_REQUEST
BAD_REQUEST
Error message
Error creating this Gitea provider
What it means
Thrown by the createGitea tRPC procedure when the underlying createGitea service call fails while inserting a new Gitea git provider. The router wraps any exception (Drizzle insert errors, unique constraint violations, invalid input) in a generic BAD_REQUEST with the original error attached as cause.
Source
Thrown at apps/dokploy/server/api/routers/gitea.ts:49
.input(apiCreateGitea)
.mutation(async ({ input, ctx }) => {
try {
const result = await createGitea(
input,
ctx.session.activeOrganizationId,
ctx.session.userId,
);
await audit(ctx, {
action: "create",
resourceType: "gitProvider",
resourceId: result.giteaId,
resourceName: input.name,
});
return result;
} catch (error) {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Error creating this Gitea provider",
cause: error,
});
}
}),
one: protectedProcedure
.input(apiFindOneGitea)
.query(async ({ input, ctx }) => {
const gitea = await findGiteaById(input.giteaId);
await assertGitProviderAccess(ctx.session, gitea.gitProvider);
return gitea;
}),
giteaProviders: protectedProcedure.query(async ({ ctx }) => {
const accessibleIds = await getAccessibleGitProviderIds(ctx.session);
View on GitHub (pinned to 546686ea35)
Solutions
- Inspect error.cause (or server logs) for the real DB/service error before treating the message as the problem
- Check the input.name and provider fields are non-empty and not already used by another Gitea provider
- Verify the database is reachable and migrations have been applied
- Retry the create after correcting the conflicting field
Example fix
// before
await api.gitea.create.mutate({ name: "", giteaUrl: "https://gitea.example" });
// after
await api.gitea.create.mutate({ name: "my-gitea", giteaUrl: "https://gitea.example.com" }); Defensive patterns
Strategy: try-catch
Validate before calling
const existing = await api.gitea.list.query();
if (existing.some((g) => g.name === newName)) throw new Error("name taken"); Type guard
const isGiteaCreateInput = (v: unknown): v is { name: string; giteaUrl: string } =>
typeof v === "object" && v !== null &&
typeof (v as any).name === "string" && (v as any).name.trim() !== "" &&
typeof (v as any).giteaUrl === "string"; Try / catch
try { await api.gitea.create.mutate(input); } catch (e) { const cause = (e as any)?.shape?.cause ?? e; console.error(cause); } Prevention
- Validate name/url client-side before submit
- Disable the submit button while in-flight to avoid duplicates
When it happens
Trigger: Calling gitea.create with a payload that fails the service layer or DB insert: duplicate provider name, missing required fields that slip past Zod, or a DB connectivity failure during the transaction.
Common situations: Re-submitting an already-existing Gitea provider name; DB schema drift after an upgrade; passing an empty/whitespace name or URL that passes schema but fails the insert.
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/3288258bec81030e.
Report an issue: GitHub.