{"record":{"id":"b9f5ec3794fe2734","repo":"Dokploy/dokploy","slug":"unauthorized-b9f5ec","errorCode":"UNAUTHORIZED","errorMessage":"Only the owner can share this provider","messagePattern":"Only the owner can share this provider","errorType":"exception","errorClass":"TRPCError","httpStatus":401,"severity":"error","filePath":"apps/dokploy/server/api/routers/git-provider.ts","lineNumber":96,"sourceCode":"\t\t\t\t\t\tgiteaId: r.gitea.giteaId,\n\t\t\t\t\t\tgiteaUrl: r.gitea.giteaUrl,\n\t\t\t\t\t\tclientId: r.gitea.clientId,\n\t\t\t\t\t\tisConfigured: !!(r.gitea.accessToken && r.gitea.refreshToken),\n\t\t\t\t\t}\n\t\t\t\t: null,\n\t\t}));\n\t}),\n\n\ttoggleShare: protectedProcedure\n\t\t.input(apiToggleShareGitProvider)\n\t\t.mutation(async ({ input, ctx }) => {\n\t\t\tconst provider = await findGitProviderById(input.gitProviderId);\n\n\t\t\tif (\n\t\t\t\tprovider.userId !== ctx.session.userId ||\n\t\t\t\tprovider.organizationId !== ctx.session.activeOrganizationId\n\t\t\t) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"UNAUTHORIZED\",\n\t\t\t\t\tmessage: \"Only the owner can share this provider\",\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tawait audit(ctx, {\n\t\t\t\taction: \"update\",\n\t\t\t\tresourceType: \"gitProvider\",\n\t\t\t\tresourceId: provider.gitProviderId,\n\t\t\t\tresourceName: provider.name ?? provider.gitProviderId,\n\t\t\t});\n\n\t\t\treturn await updateGitProvider(input.gitProviderId, {\n\t\t\t\tsharedWithOrganization: input.sharedWithOrganization,\n\t\t\t});\n\t\t}),\n\n\tallForPermissions: withPermission(\"member\", \"update\")","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/git-provider.ts#L78-L114","documentation":"Thrown by git-provider share when the provider row's userId or organizationId does not match the session user / active organization. Sharing a Git provider is restricted to the user who owns it within the same org.","triggerScenarios":"Calling gitProvider.share with a gitProviderId owned by a different user, or owned by you but under a different active organization.","commonSituations":"Teammates trying to share an org-mate's provider; owner attempting to share while the wrong org is active in a multi-org session.","solutions":["Have the provider's owner (provider.userId) perform the share","Ensure the active organization matches provider.organizationId","Re-check ownership with gitProvider.one before calling share"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const p = await trpc.gitProvider.one.query({ gitProviderId });\nif (p.userId !== session.userId || p.organizationId !== activeOrgId) throw new Error('not provider owner');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only expose share action to the provider's creator","Verify active org matches provider org"],"tags":["dokploy","git-provider","trpc","authorization","share"],"backgroundTag":"resource-ownership-mismatch","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}