{"record":{"id":"91d301ec98d83d9f","repo":"Dokploy/dokploy","slug":"bad-request-91d301","errorCode":"BAD_REQUEST","errorMessage":"Error deleting this Git provider","messagePattern":"Error deleting this Git provider","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"apps/dokploy/server/api/routers/git-provider.ts","lineNumber":174,"sourceCode":"\t\t\t\tif (!isPrivileged && gitProvider.userId !== ctx.session.userId) {\n\t\t\t\t\tthrow new TRPCError({\n\t\t\t\t\t\tcode: \"UNAUTHORIZED\",\n\t\t\t\t\t\tmessage: \"You can only delete your own Git providers\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tawait audit(ctx, {\n\t\t\t\t\taction: \"delete\",\n\t\t\t\t\tresourceType: \"gitProvider\",\n\t\t\t\t\tresourceId: gitProvider.gitProviderId,\n\t\t\t\t\tresourceName: gitProvider.name ?? gitProvider.gitProviderId,\n\t\t\t\t});\n\t\t\t\treturn await removeGitProvider(input.gitProviderId);\n\t\t\t} catch (error) {\n\t\t\t\tconst message =\n\t\t\t\t\terror instanceof Error\n\t\t\t\t\t\t? error.message\n\t\t\t\t\t\t: \"Error deleting this Git provider\";\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\t\tmessage,\n\t\t\t\t});\n\t\t\t}\n\t\t}),\n});\n","sourceCodeStart":156,"sourceCodeEnd":181,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/git-provider.ts#L156-L181","documentation":"Catch-all for git-provider remove: any error from findGitProviderById (e.g. not found) or removeGitProvider that is not a TRPCError is rethrown as BAD_REQUEST. If the original error is not an Error instance, the generic message 'Error deleting this Git provider' is used.","triggerScenarios":"Deleting a gitProviderId that no longer exists (throwing inside findGitProviderById), or a DB failure during removeGitProvider. Non-Error throwables produce the generic message.","commonSituations":"Double-click delete where the first request already removed the row; stale provider list in the UI; DB constraint from linked deployments still referencing the provider.","solutions":["Refresh the provider list and confirm the ID still exists before retrying","Detach deployments using the provider, then delete","Check the original error message when present to identify FK/constraint failures"],"exampleFix":"// before\nawait trpc.gitProvider.remove.mutate({ gitProviderId });\n// after\nconst providers = await trpc.gitProvider.list.query();\nif (!providers.some((p) => p.gitProviderId === gitProviderId)) return; // already gone\nawait trpc.gitProvider.remove.mutate({ gitProviderId });","handlingStrategy":"try-catch","validationCode":"const exists = (await trpc.gitProvider.list.query()).some(p => p.gitProviderId === gitProviderId);\nif (!exists) return; // treat as already deleted","typeGuard":null,"tryCatchPattern":"try { await removeGitProvider(id) } catch (e) { if (e instanceof TRPCClientError && e.data?.code === 'BAD_REQUEST') { refreshList(); surface(e.message); } else throw e; }","preventionTips":["Guard against double-submit on delete buttons","Detach deployments from a provider before deleting it"],"tags":["dokploy","git-provider","trpc","database","delete"],"backgroundTag":"crud-operation-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}