{"record":{"id":"3288258bec81030e","repo":"Dokploy/dokploy","slug":"bad-request-328825","errorCode":"BAD_REQUEST","errorMessage":"Error creating this Gitea provider","messagePattern":"Error creating this Gitea provider","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"apps/dokploy/server/api/routers/gitea.ts","lineNumber":49,"sourceCode":"\t\t.input(apiCreateGitea)\n\t\t.mutation(async ({ input, ctx }) => {\n\t\t\ttry {\n\t\t\t\tconst result = await createGitea(\n\t\t\t\t\tinput,\n\t\t\t\t\tctx.session.activeOrganizationId,\n\t\t\t\t\tctx.session.userId,\n\t\t\t\t);\n\n\t\t\t\tawait audit(ctx, {\n\t\t\t\t\taction: \"create\",\n\t\t\t\t\tresourceType: \"gitProvider\",\n\t\t\t\t\tresourceId: result.giteaId,\n\t\t\t\t\tresourceName: input.name,\n\t\t\t\t});\n\n\t\t\t\treturn result;\n\t\t\t} catch (error) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\t\tmessage: \"Error creating this Gitea provider\",\n\t\t\t\t\tcause: error,\n\t\t\t\t});\n\t\t\t}\n\t\t}),\n\n\tone: protectedProcedure\n\t\t.input(apiFindOneGitea)\n\t\t.query(async ({ input, ctx }) => {\n\t\t\tconst gitea = await findGiteaById(input.giteaId);\n\t\t\tawait assertGitProviderAccess(ctx.session, gitea.gitProvider);\n\t\t\treturn gitea;\n\t\t}),\n\n\tgiteaProviders: protectedProcedure.query(async ({ ctx }) => {\n\t\tconst accessibleIds = await getAccessibleGitProviderIds(ctx.session);\n","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/gitea.ts#L31-L67","documentation":"Thrown by the createGitea tRPC procedure when the underlying createGitea service call fails while inserting a new Gitea git provider. The router wraps any exception (Drizzle insert errors, unique constraint violations, invalid input) in a generic BAD_REQUEST with the original error attached as cause.","triggerScenarios":"Calling gitea.create with a payload that fails the service layer or DB insert: duplicate provider name, missing required fields that slip past Zod, or a DB connectivity failure during the transaction.","commonSituations":"Re-submitting an already-existing Gitea provider name; DB schema drift after an upgrade; passing an empty/whitespace name or URL that passes schema but fails the insert.","solutions":["Inspect error.cause (or server logs) for the real DB/service error before treating the message as the problem","Check the input.name and provider fields are non-empty and not already used by another Gitea provider","Verify the database is reachable and migrations have been applied","Retry the create after correcting the conflicting field"],"exampleFix":"// before\nawait api.gitea.create.mutate({ name: \"\", giteaUrl: \"https://gitea.example\" });\n// after\nawait api.gitea.create.mutate({ name: \"my-gitea\", giteaUrl: \"https://gitea.example.com\" });","handlingStrategy":"try-catch","validationCode":"const existing = await api.gitea.list.query();\nif (existing.some((g) => g.name === newName)) throw new Error(\"name taken\");","typeGuard":"const isGiteaCreateInput = (v: unknown): v is { name: string; giteaUrl: string } =>\n  typeof v === \"object\" && v !== null &&\n  typeof (v as any).name === \"string\" && (v as any).name.trim() !== \"\" &&\n  typeof (v as any).giteaUrl === \"string\";","tryCatchPattern":"try { await api.gitea.create.mutate(input); } catch (e) { const cause = (e as any)?.shape?.cause ?? e; console.error(cause); }","preventionTips":["Validate name/url client-side before submit","Disable the submit button while in-flight to avoid duplicates"],"tags":["gitea","git-provider","database-insert","trpc"],"backgroundTag":"database-insert-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}