Dokploy/dokploy · error · TRPCError

BAD_REQUEST

BAD_REQUEST

Error message

Error creating this Gitlab provider

What it means

Thrown by the Gitlab create procedure when createGitlab fails while inserting the new GitLab provider record. Like the Gitea twin, it is a generic wrapper — the true cause (constraint violation, invalid column data, DB error) is in error.cause.

Source

Thrown at apps/dokploy/server/api/routers/gitlab.ts:48

	create: withPermission("gitProviders", "create")
		.input(apiCreateGitlab)
		.mutation(async ({ input, ctx }) => {
			try {
				const result = await createGitlab(
					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 Gitlab provider",
					cause: error,
				});
			}
		}),
	one: protectedProcedure
		.input(apiFindOneGitlab)
		.query(async ({ input, ctx }) => {
			const gitlab = await findGitlabById(input.gitlabId);
			await assertGitProviderAccess(ctx.session, gitlab.gitProvider);
			return gitlab;
		}),
	gitlabProviders: protectedProcedure.query(async ({ ctx }) => {
		const accessibleIds = await getAccessibleGitProviderIds(ctx.session);

		let result = await db.query.gitlab.findMany({
			with: {

View on GitHub (pinned to 546686ea35)

Solutions

  1. Log/inspect error.cause for the specific DB error
  2. Unique-ify the provider name and re-submit
  3. Run pending migrations (dokploy upgrade path) if the insert complains about missing columns
  4. Guard the form against double submission

Example fix

// before
await api.gitlab.create.mutate({ name: "gitlab" }); // name already exists
// after
await api.gitlab.create.mutate({ name: "gitlab-prod" });
Defensive patterns

Strategy: try-catch

Validate before calling

const list = await api.gitlab.list.query();
if (list.some((p) => p.name === input.name)) throw new Error("name taken");

Type guard

const isGitlabCreateInput = (v: unknown): v is { name: string } =>
  typeof v === "object" && v !== null && typeof (v as any).name === "string" && (v as any).name.trim() !== "";

Try / catch

try { await api.gitlab.create.mutate(input); } catch (e) { inspect((e as any).shape?.cause); }

Prevention

When it happens

Trigger: Creating a GitLab provider whose name collides with an existing entry, or whose fields fail the service-layer/DB insert; transient DB outage during creation.

Common situations: Duplicate friendly-name on retry after a double-submit; schema drift after Dokploy upgrade without migrations; missing required column value (e.g. empty url) that Zod allowed as optional.

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/444c0ab3dbd6613e. Report an issue: GitHub.