Dokploy/dokploy · error · Error

Failed to create rollback

Error message

Failed to create rollback

What it means

In createRollback's transaction, the insert into `rollbacks` with .returning() returned no first row, so a plain Error 'Failed to create rollback' is thrown (not a TRPCError — this service uses vanilla Errors). The transaction rolls back, so no rollback record or deployment linkage is persisted.

Source

Thrown at packages/server/src/services/rollbacks.ts:46

import {
	findRegistryByIdWithCredentials,
	type Registry,
	safeDockerLoginCommand,
} from "./registry";

export const createRollback = async (
	input: z.infer<typeof createRollbackSchema>,
) => {
	return await db.transaction(async (tx) => {
		const { fullContext, ...other } = input;
		const rollback = await tx
			.insert(rollbacks)
			.values(other)
			.returning()
			.then((res) => res[0]);

		if (!rollback) {
			throw new Error("Failed to create rollback");
		}

		const tagImage = `${input.appName}:v${rollback.version}`;
		const deployment = await findDeploymentById(rollback.deploymentId);

		if (!deployment?.applicationId) {
			throw new Error("Deployment not found");
		}

		const {
			deployments: _,
			bitbucket,
			github,
			gitlab,
			gitea,
			...rest
		} = await findApplicationById(deployment.applicationId);

View on GitHub (pinned to 546686ea35)

Solutions

  1. Apply pending migrations so the rollbacks table matches the drizzle schema
  2. Validate the createRollback payload (deploymentId, version) before calling
  3. Inspect server logs for the underlying postgres error during the insert
Defensive patterns

Strategy: validation

Validate before calling

const parsed = createRollbackSchema.safeParse(input);
if (!parsed.success) throw new Error(parsed.error.message);

Try / catch

try { await createRollback(input); } catch (e) { if (/Failed to create rollback/.test((e as Error).message)) { /* check migrations/logs */ } throw e; }

Prevention

When it happens

Trigger: The insert values (deploymentId, version, appName-derived fields) failing to produce a row — schema drift on the `rollbacks` table, a missing NOT NULL default, or malformed input after zod parsing of createRollbackSchema.

Common situations: Database migrations not applied after upgrading Dokploy (new columns like fullContext/image), or an API caller sending an incomplete payload.

Related errors


AI-assisted analysis of Dokploy/dokploy@546686ea35 (2026-08-27). Data as JSON: /api/errors/6db6bb12e7fa32e8. Report an issue: GitHub.