{"record":{"id":"39d42b7cb954789a","repo":"Dokploy/dokploy","slug":"unauthorized-39d42b","errorCode":"UNAUTHORIZED","errorMessage":"You don't have access to this server.","messagePattern":"You don't have access to this server\\.","errorType":"exception","errorClass":"TRPCError","httpStatus":401,"severity":"error","filePath":"apps/dokploy/server/api/routers/deployment.ts","lineNumber":60,"sourceCode":"\t\t\t\tdeployment: [\"read\"],\n\t\t\t});\n\t\t\treturn await findAllDeploymentsByApplicationId(input.applicationId);\n\t\t}),\n\n\tallByCompose: protectedProcedure\n\t\t.input(apiFindAllByCompose)\n\t\t.query(async ({ input, ctx }) => {\n\t\t\tawait checkServicePermissionAndAccess(ctx, input.composeId, {\n\t\t\t\tdeployment: [\"read\"],\n\t\t\t});\n\t\t\treturn await findAllDeploymentsByComposeId(input.composeId);\n\t\t}),\n\tallByServer: withPermission(\"deployment\", \"read\")\n\t\t.input(apiFindAllByServer)\n\t\t.query(async ({ input, ctx }) => {\n\t\t\tconst targetServer = await findServerById(input.serverId);\n\t\t\tif (targetServer.organizationId !== ctx.session.activeOrganizationId) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"UNAUTHORIZED\",\n\t\t\t\t\tmessage: \"You don't have access to this server.\",\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn await findAllDeploymentsByServerId(input.serverId);\n\t\t}),\n\tallCentralized: withPermission(\"deployment\", \"read\").query(\n\t\tasync ({ ctx }) => {\n\t\t\tconst orgId = ctx.session.activeOrganizationId;\n\t\t\tconst accessedServices =\n\t\t\t\tctx.user.role !== \"owner\" && ctx.user.role !== \"admin\"\n\t\t\t\t\t? (await findMemberByUserId(ctx.user.id, orgId)).accessedServices\n\t\t\t\t\t: null;\n\t\t\tif (accessedServices !== null && accessedServices.length === 0) {\n\t\t\t\treturn [];\n\t\t\t}\n\t\t\treturn findAllDeploymentsCentralized(orgId, accessedServices);\n\t\t},","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/deployment.ts#L42-L78","documentation":"Ownership check in deployment.allByServer: the server referenced by serverId must belong to the session's active organization or the query is rejected.","triggerScenarios":"Querying deployments with a serverId from another organization or a stale/rotated server record.","commonSituations":"Multi-org workspaces; deleted servers still referenced by cached client state; copy-pasted server IDs.","solutions":["Use a serverId from the current organization's server list","Refetch servers after org or membership changes","Confirm the server exists and is org-owned"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const s = await findServerById(serverId);\nif (s.organizationId !== activeOrgId) throw new Error('Wrong org');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only servers listed for the active organization","Refresh server list after membership changes"],"tags":["dokploy","authorization","deployment","server-access"],"backgroundTag":"authorization-denied","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}