{"record":{"id":"dfdb17b70b6fd999","repo":"Dokploy/dokploy","slug":"not-found-dfdb17","errorCode":"NOT_FOUND","errorMessage":"Destination not found","messagePattern":"Destination not found","errorType":"exception","errorClass":"TRPCError","httpStatus":404,"severity":"warning","filePath":"packages/server/src/services/destination.ts","lineNumber":40,"sourceCode":"\t\t.returning()\n\t\t.then((value) => value[0]);\n\n\tif (!newDestination) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"BAD_REQUEST\",\n\t\t\tmessage: \"Error input: Inserting destination\",\n\t\t});\n\t}\n\n\treturn newDestination;\n};\n\nexport const findDestinationById = async (destinationId: string) => {\n\tconst destination = await db.query.destinations.findFirst({\n\t\twhere: and(eq(destinations.destinationId, destinationId)),\n\t});\n\tif (!destination) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"NOT_FOUND\",\n\t\t\tmessage: \"Destination not found\",\n\t\t});\n\t}\n\treturn destination;\n};\n\nexport const removeDestinationById = async (\n\tdestinationId: string,\n\torganizationId: string,\n) => {\n\tconst result = await db\n\t\t.delete(destinations)\n\t\t.where(\n\t\t\tand(\n\t\t\t\teq(destinations.destinationId, destinationId),\n\t\t\t\teq(destinations.organizationId, organizationId),\n\t\t\t),","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/destination.ts#L22-L58","documentation":"findDestinationById queries the destinations table by destinationId and throws NOT_FOUND when no row matches. It is the standard 'resource does not exist' error for backup/upload destinations used across destination lookups.","triggerScenarios":"Looking up a destination by an ID that doesn't exist: deleted destination, typo/truncated UUID, or an ID from a different database/environment.","commonSituations":"Stale UI lists after a destination was removed elsewhere; copying IDs between environments; frontend caching old destination references after re-provisioning the database.","solutions":["Verify the destination still exists (list destinations) and re-fetch fresh IDs","Handle 404 by refreshing the destination list in the UI","Check for environment mismatch (dev vs prod IDs)","Guard calls with an existence check before dependent operations"],"exampleFix":"// before\nconst dest = await findDestinationById(id);\n// after: check first and degrade gracefully\nconst exists = await db.query.destinations.findFirst({ where: eq(destinations.destinationId, id) });\nif (!exists) {\n  // refresh list / prompt user instead of throwing\n}","handlingStrategy":"type-guard","validationCode":"const row = await db.query.destinations.findFirst({ where: eq(destinations.destinationId, id) });\nif (!row) { /* refresh destination list, don't call downstream ops */ }","typeGuard":"const isDestination = (d: unknown): d is Destination =>\n  !!d && typeof (d as Destination).destinationId === \"string\";","tryCatchPattern":"try { return await findDestinationById(id); } catch (e) { if (e instanceof TRPCError && e.code === \"NOT_FOUND\") return null; throw e; }","preventionTips":["Refresh IDs after deletions or env re-provisioning","Never hardcode destination IDs","Handle 404 by reloading lists"],"tags":["not-found","destination","lookup"],"backgroundTag":"resource-not-found","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}