{"record":{"id":"d5d461e7018a01a8","repo":"Dokploy/dokploy","slug":"not-found-d5d461","errorCode":"NOT_FOUND","errorMessage":"SSO provider not found","messagePattern":"SSO provider not found","errorType":"exception","errorClass":"TRPCError","httpStatus":404,"severity":"error","filePath":"packages/server/src/services/proprietary/forward-auth.ts","lineNumber":79,"sourceCode":"\t\tissuer: provider.issuer,\n\t\tscopes: parsed.scopes,\n\t\tskipDiscovery: parsed.skipDiscovery,\n\t};\n};\n\nconst findProviderForOrg = async (\n\tproviderId: string,\n\torganizationId: string,\n) => {\n\tconst provider = await db.query.ssoProvider.findFirst({\n\t\twhere: and(\n\t\t\teq(ssoProvider.providerId, providerId),\n\t\t\teq(ssoProvider.organizationId, organizationId),\n\t\t),\n\t\tcolumns: { providerId: true, issuer: true, oidcConfig: true },\n\t});\n\tif (!provider) {\n\t\tthrow new TRPCError({\n\t\t\tcode: \"NOT_FOUND\",\n\t\t\tmessage: \"SSO provider not found\",\n\t\t});\n\t}\n\treturn provider;\n};\n\nexport const listSsoProvidersForOrg = async (organizationId: string) => {\n\treturn db.query.ssoProvider.findMany({\n\t\twhere: and(\n\t\t\teq(ssoProvider.organizationId, organizationId),\n\t\t\tisNotNull(ssoProvider.oidcConfig),\n\t\t),\n\t\tcolumns: { providerId: true, issuer: true, domain: true },\n\t\torderBy: [asc(ssoProvider.createdAt)],\n\t});\n};\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/packages/server/src/services/proprietary/forward-auth.ts#L61-L97","documentation":"findProviderForOrg looks up an SSO provider by providerId scoped to an organizationId. If no row matches both, it throws NOT_FOUND — the organization does not have that SSO provider (wrong id, deleted provider, or cross-org mixup).","triggerScenarios":"Calling the forward-auth provider resolver with a providerId that does not exist for the given organizationId — e.g. a provider from another org, a deleted provider, or a stale id in client state.","commonSituations":"Switched active organization but the client still sends the previous org's providerId; provider was deleted and recreated with a new id; manual API call with a mistyped providerId.","solutions":["List the org's SSO providers and use the current providerId for the active organization","Refresh client state after org switching or provider re-creation","Ensure the organizationId passed matches the org that owns the provider"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const providers = await listSsoProviders(organizationId);\nif (!providers.some(p => p.providerId === providerId)) { /* refresh provider selection */ }","typeGuard":null,"tryCatchPattern":"try { await provider(providerId, organizationId) } catch (e) { if (e instanceof TRPCError && e.code === 'NOT_FOUND') { /* reload providers for active org */ } }","preventionTips":["Scope provider selection to the active organization","Clear provider selection on org switch"],"tags":["sso","not-found","provider","multi-tenant"],"backgroundTag":"resource-not-found","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}