{"record":{"id":"64498cca22768c10","repo":"Dokploy/dokploy","slug":"bad-request-64498c","errorCode":"BAD_REQUEST","errorMessage":"err instanceof Error ? err?.message : `Error: ${err}`","messagePattern":"err instanceof Error \\? err\\?\\.message : `Error: (.+?)`","errorType":"exception","errorClass":"TRPCError","httpStatus":400,"severity":"error","filePath":"apps/dokploy/server/api/routers/github.ts","lineNumber":89,"sourceCode":"\t\t\t\t\tgitProvider: {\n\t\t\t\t\t\t...provider.gitProvider,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t});\n\n\t\treturn filtered;\n\t}),\n\n\ttestConnection: protectedProcedure\n\t\t.input(apiFindOneGithub)\n\t\t.mutation(async ({ input, ctx }) => {\n\t\t\ttry {\n\t\t\t\tconst github = await findGithubById(input.githubId);\n\t\t\t\tawait assertGitProviderAccess(ctx.session, github.gitProvider);\n\t\t\t\tconst result = await getGithubRepositories(input.githubId);\n\t\t\t\treturn `Found ${result.length} repositories`;\n\t\t\t} catch (err) {\n\t\t\t\tthrow new TRPCError({\n\t\t\t\t\tcode: \"BAD_REQUEST\",\n\t\t\t\t\tmessage: err instanceof Error ? err?.message : `Error: ${err}`,\n\t\t\t\t});\n\t\t\t}\n\t\t}),\n\tupdate: withPermission(\"gitProviders\", \"create\")\n\t\t.input(apiUpdateGithub)\n\t\t.mutation(async ({ input, ctx }) => {\n\t\t\tawait updateGitProvider(input.gitProviderId, {\n\t\t\t\tname: input.name,\n\t\t\t\torganizationId: ctx.session.activeOrganizationId,\n\t\t\t});\n\n\t\t\tawait updateGithub(input.githubId, {\n\t\t\t\t...input,\n\t\t\t});\n\n\t\t\tawait audit(ctx, {","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/Dokploy/dokploy/blob/546686ea3587f12ec5652217dedd9f7960fb6d15/apps/dokploy/server/api/routers/github.ts#L71-L107","documentation":"The github.testGithubProvider procedure chains findGithubById, a permission assertion (assertGitProviderAccess), and getGithubRepositories; any failure in that chain is wrapped with the original message preserved. Most commonly it is an auth failure against the GitHub API or a permission denial from the session check.","triggerScenarios":"Expired/revoked GitHub access token; the session's user lacks access to the git provider's owning organization (assertGitProviderAccess throws); GitHub API rate-limit or network failure from the server.","commonSituations":"GitHub App / OAuth token expired after rotation; user switched active organization so the provider is no longer accessible; server IP rate-limited by GitHub API.","solutions":["Check whether the message is a permission denial — if so switch back to the organization that owns the provider or grant access","If 401/Bad credentials, reconnect the GitHub provider with a fresh token","If rate-limited, wait and retry; check X-RateLimit headers in server logs","Verify network egress to api.github.com"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await api.github.testGithubProvider.query({ githubId }); } catch (e) { if (/permission|access/i.test((e as Error).message)) switchOrg(); else reconnectProvider(); }","preventionTips":["Re-test provider connections after org switches","Monitor token expiry for GitHub Apps"],"tags":["github","git-provider","api-request","auth","trpc"],"backgroundTag":"git-provider-auth-failed","analyzedSha":"546686ea3587f12ec5652217dedd9f7960fb6d15","analyzedAt":"2026-08-27T05:18:58.095Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}