Dokploy/dokploy · error · TRPCError

BAD_REQUEST

BAD_REQUEST

Error message

Error creating tag: ${error instanceof Error ? error.message : error}

What it means

Catch-all in tag.create: any error other than the unique_org_tag_name conflict is rethrown as BAD_REQUEST with the original error message embedded. Commonly wraps Drizzle/Postgres failures such as NOT NULL violations, invalid identifiers, or connection problems during the insert.

Source

Thrown at apps/dokploy/server/api/routers/tag.ts:42

					.values({
						name: input.name,
						color: input.color,
						organizationId: ctx.session.activeOrganizationId,
					})
					.returning();

				return newTag[0];
			} catch (error) {
				if (
					error instanceof Error &&
					error.message.includes("unique_org_tag_name")
				) {
					throw new TRPCError({
						code: "CONFLICT",
						message: "A tag with this name already exists in your organization",
					});
				}
				throw new TRPCError({
					code: "BAD_REQUEST",
					message: `Error creating tag: ${error instanceof Error ? error.message : error}`,
					cause: error,
				});
			}
		}),

	all: protectedProcedure.query(async ({ ctx }) => {
		try {
			const organizationTags = await db.query.tags.findMany({
				where: eq(tags.organizationId, ctx.session.activeOrganizationId),
				orderBy: (tags, { asc }) => [asc(tags.name)],
			});

			return organizationTags;
		} catch (error) {
			throw new TRPCError({
				code: "INTERNAL_SERVER_ERROR",

View on GitHub (pinned to 546686ea35)

Solutions

  1. Read the embedded error.message — it names the real Postgres/Drizzle cause
  2. Run pending migrations (dokploy upgrade / db push) so the tags table matches the code
  3. Verify DB connectivity and credentials, then retry the create
  4. If the message mentions a constraint or column, fix the input or schema accordingly
Defensive patterns

Strategy: try-catch

Try / catch

try { await api.tag.create({ name }); }
catch (e) {
  const msg = e.message ?? '';
  if (e.shape?.data?.code === 'CONFLICT') return; // duplicate
  if (/connection|ECONNREFUSED|timeout/i.test(msg)) retryLater();
  else throw e;
}

Prevention

When it happens

Trigger: tag.create throwing for reasons other than a duplicate name — DB unreachable mid-insert, schema drift (missing column after an incomplete migration), or invalid input that slipped past zod validation.

Common situations: Database migration not applied after upgrading Dokploy; transient DB outage; manually edited schema; Postgres extension/permission issues.

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/41759bc736f4c990. Report an issue: GitHub.