{"record":{"id":"3ba3b84ece625db7","repo":"Dokploy/dokploy","slug":"not-found-3ba3b8","errorCode":"NOT_FOUND","errorMessage":"Redirect not found","messagePattern":"Redirect not found","errorType":"exception","errorClass":"TRPCError","httpStatus":404,"severity":"error","filePath":"packages/server/src/services/redirect.ts","lineNumber":19,"sourceCode":"import { db } from \"@dokploy/server/db\";\nimport { type apiCreateRedirect, redirects } from \"@dokploy/server/db/schema\";\nimport {\n\tcreateRedirectMiddleware,\n\tremoveRedirectMiddleware,\n\tupdateRedirectMiddleware,\n} from \"@dokploy/server/utils/traefik/redirect\";\nimport { TRPCError } from \"@trpc/server\";\nimport { eq } from \"drizzle-orm\";\nimport type { z } from \"zod\";\nimport { findApplicationById } from \"./application\";\nexport type Redirect = typeof redirects.$inferSelect;\n\nexport const findRedirectById = async (redirectId: string) => {\n\tconst application = await db.query.redirects.findFirst({\n\t\twhere: eq(redirects.redirectId, redirectId),\n\t});\n\tif (!application) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"NOT_FOUND\",\n\t\t\tmessage: \"Redirect not found\",\n\t\t});\n\t}\n\treturn application;\n};\n\nexport const createRedirect = async (\n\tredirectData: z.infer<typeof apiCreateRedirect>,\n) => {\n\ttry {\n\t\tawait db.transaction(async (tx) => {\n\t\t\tconst redirect = await tx\n\t\t\t\t.insert(redirects)\n\t\t\t\t.values({\n\t\t\t\t\t...redirectData,\n\t\t\t\t})\n\t\t\t\t.returning()","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/redirect.ts#L1-L37","documentation":"findRedirectById looks up a redirect row by redirectId and throws NOT_FOUND when none exists. It is the standard lookup guard for redirect read/update/delete flows; the id supplied does not match any redirect record.","triggerScenarios":"Calling a redirect operation (read/update/delete) with a redirectId that doesn't exist, was already deleted, or is malformed.","commonSituations":"Redirect was deleted in another tab but the list state is stale; copy-paste/truncated UUID in direct API calls; concurrent delete racing a read/update.","solutions":["Verify the redirect exists by re-fetching the redirects list for the application","Refresh client state and retry with a current redirectId","If it should exist, check the redirects table for the id"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const list = await listRedirects(applicationId);\nif (!list.some(r => r.redirectId === redirectId)) { /* drop stale reference */ }","typeGuard":null,"tryCatchPattern":"try { await findRedirectById(id) } catch (e) { if (e instanceof TRPCError && e.code === 'NOT_FOUND') { /* remove from local list */ } }","preventionTips":["Refresh the redirect list before acting on one","Handle double-delete races gracefully"],"tags":["trpc","not-found","redirect","lookup"],"backgroundTag":"resource-not-found","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}