Dokploy/dokploy · error · TRPCError

BAD_REQUEST

BAD_REQUEST

Error message

Error input: Inserting mongo database

What it means

Thrown by createMongo when the Drizzle INSERT into the mongo table with .returning() yields no row — the database-level insert failed after the uniqueness check passed.

Source

Thrown at packages/server/src/services/mongo.ts:45

			code: "CONFLICT",
			message: "Service with this 'AppName' already exists",
		});
	}

	const newMongo = await db
		.insert(mongo)
		.values({
			...input,
			databasePassword: input.databasePassword
				? input.databasePassword
				: generatePassword(),
			appName,
		})
		.returning()
		.then((value) => value[0]);

	if (!newMongo) {
		throw new TRPCError({
			code: "BAD_REQUEST",
			message: "Error input: Inserting mongo database",
		});
	}

	return newMongo;
};

export const findMongoById = async (mongoId: string) => {
	const result = await db.query.mongo.findFirst({
		where: eq(mongo.mongoId, mongoId),
		with: {
			environment: {
				with: {
					project: true,
				},
			},
			mounts: true,

View on GitHub (pinned to 546686ea35)

Solutions

  1. Inspect server logs for the Postgres error behind the failed insert
  2. If it's a race, re-fetch: the row may exist under the same name (treat as 409)
  3. Apply pending Drizzle migrations
Defensive patterns

Strategy: try-catch

Try / catch

try { await createMongo(input); } catch (e) { if (e.shape?.data?.code === 'BAD_REQUEST') { await verifyOrCreateWithUniqueName(input); } }

Prevention

When it happens

Trigger: A NOT NULL/enum/foreign-key violation on the mongo table insert, a dropped connection, or a concurrent create race that beats this request between check and insert.

Common situations: Schema drift after an upgrade, missing column defaults, or parallel provisioning scripts racing on similar names.

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/9c03879286d56f1b. Report an issue: GitHub.