{"record":{"id":"60db77da0888980b","repo":"Dokploy/dokploy","slug":"not-found-60db77","errorCode":"NOT_FOUND","errorMessage":"Organization not found","messagePattern":"Organization not found","errorType":"exception","errorClass":"TRPCError","httpStatus":404,"severity":"error","filePath":"apps/dokploy/server/api/routers/organization.ts","lineNumber":145,"sourceCode":"\t\t\t});\n\t\t}),\n\tupdate: protectedProcedure\n\t\t.input(\n\t\t\tz.object({\n\t\t\t\torganizationId: z.string(),\n\t\t\t\tname: z.string(),\n\t\t\t\tlogo: z.string().optional(),\n\t\t\t\tdefaultRole: z.string().min(1).nullable().optional(),\n\t\t\t}),\n\t\t)\n\t\t.mutation(async ({ ctx, input }) => {\n\t\t\t// First, verify the organization exists\n\t\t\tconst org = await db.query.organization.findFirst({\n\t\t\t\twhere: eq(organization.id, input.organizationId),\n\t\t\t});\n\n\t\t\tif (!org) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"NOT_FOUND\",\n\t\t\t\t\tmessage: \"Organization not found\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\t// Verify user is a member of this organization\n\t\t\tconst userMember = await db.query.member.findFirst({\n\t\t\t\twhere: and(\n\t\t\t\t\teq(member.organizationId, input.organizationId),\n\t\t\t\t\teq(member.userId, ctx.user.id),\n\t\t\t\t),\n\t\t\t});\n\n\t\t\tif (!userMember) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"FORBIDDEN\",\n\t\t\t\t\tmessage: \"You are not a member of this organization\",\n\t\t\t\t});","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/organization.ts#L127-L163","documentation":"Existence check at the top of the update-organization mutation: it queries the organization table by id and throws NOT_FOUND when no row matches. The organization was deleted, the id is wrong (or from another instance), or it's a UUID typo/paste error.","triggerScenarios":"Calling organization.update with an organizationId that doesn't exist in the DB — deleted org, stale reference in the UI, or malformed UUID.","commonSituations":"Org deleted in another tab/session while the settings page was open; environment mismatch (dev id used against prod); UUID truncated when copied; restore-from-backup dropped the row.","solutions":["List your organizations and confirm the id exists","Re-fetch the org id in the current environment before updating","Check for soft-delete/recent deletion in audit logs","If the org should exist, inspect the organization table directly"],"exampleFix":"// before\nawait trpc.organization.update.mutate({ organizationId: staleId, name: 'X' }); // NOT_FOUND\n\n// after\nconst org = (await trpc.organization.all.query()).find(o => o.name === 'X');\nif (org) await trpc.organization.update.mutate({ organizationId: org.organizationId, name: 'X2' });","handlingStrategy":"validation","validationCode":"const exists = (await trpc.organization.all.query()).some(o => o.organizationId === organizationId);\nif (!exists) throw new Error('Organization no longer exists');","typeGuard":"const isUuid = (id: unknown): id is string => typeof id === 'string' && /^[0-9a-f-]{36}$/i.test(id);","tryCatchPattern":"try { await update(input); } catch (e) { if (getTRPCCode(e) === 'NOT_FOUND') { await refetchOrgs(); showGone(); } else throw e; }","preventionTips":["Refresh org list before edits","Disable double-submit","Never copy org IDs between environments"],"tags":["trpc","not-found","organization","uuid"],"backgroundTag":"resource-not-found","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}