Dokploy/dokploy · error · Error

Deployment not found

Error message

Deployment not found

What it means

createRollback loads the deployment referenced by rollback.deploymentId via findDeploymentById; if it does not exist or lacks an applicationId, a plain Error 'Deployment not found' aborts the transaction. The rollback needs the deployment to snapshot the application's full config (registries, sources) into fullContext.

Source

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

	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);

		const registry = rest.registryId
			? await findRegistryByIdWithCredentials(rest.registryId)
			: rest.registry;
		const buildRegistry = rest.buildRegistryId
			? await findRegistryByIdWithCredentials(rest.buildRegistryId)
			: rest.buildRegistry;
		const rollbackRegistry = rest.rollbackRegistryId

View on GitHub (pinned to 546686ea35)

Solutions

  1. Verify the deployment still exists and belongs to the intended application before creating the rollback
  2. Re-deploy the application to generate a fresh deployment, then create the rollback from it
  3. If rows were deleted manually, repair dangling references in the rollbacks table

Example fix

// before
const deployment = await findDeploymentById(rollback.deploymentId);
if (!deployment?.applicationId) throw new Error("Deployment not found");

// after
const deployment = await findDeploymentById(rollback.deploymentId).catch(() => null);
if (!deployment?.applicationId) {
  throw new Error(`Deployment ${rollback.deploymentId} not found; redeploy the app first`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

const dep = await findDeploymentById(deploymentId).catch(() => null);
if (!dep?.applicationId) throw new Error(`Deployment ${deploymentId} missing; cannot snapshot`);

Type guard

const hasApplication = (d: unknown): d is { applicationId: string } =>
  typeof d === "object" && d !== null && typeof (d as any).applicationId === "string";

Try / catch

try { await createRollback(input); } catch (e) { if (/Deployment not found/.test((e as Error).message)) { /* redeploy then retry */ } throw e; }

Prevention

When it happens

Trigger: Creating a rollback for a deploymentId that was deleted, belongs to a different app, or is a dangling FK after manual DB edits or partial cleanup.

Common situations: Old deployments purged by retention cleanup while the UI still offers rollback; DB rows removed manually; deployment record created outside normal flow.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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