Skip to content

Commit 30e8d9b

Browse files
CyrilBIENNEclaude
andcommitted
fix(preview-deployment): refetch github provider before authenticating
`findApplicationById` redacts `githubPrivateKey` from the `github` relation, but `createPreviewDeployment` passed that redacted object straight to `authGithub`. Since `haveGithubRequirements` requires the private key, it always returned false and `authGithub` threw `TRPCError NOT_FOUND: "Github Account not configured correctly"`. That throw is uncaught in `pages/api/deploy/github.ts`, so every `pull_request` webhook returned a bare 500 and no preview deployment was ever created. Resolve the provider through `findGithubById(application.githubId)` instead, matching how every other call site obtains credentials. This keeps the redaction introduced for `findApplicationById` intact. Fixes Dokploy#4898 Co-Authored-By: Claude Opus 5 <[email protected]>
1 parent 5df820a commit 30e8d9b

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

‎packages/server/src/services/preview-deployment.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { manageDomain } from "../utils/traefik/domain";
1717
import { findApplicationById } from "./application";
1818
import { removeDeploymentsByPreviewDeploymentId } from "./deployment";
1919
import { createDomain } from "./domain";
20-
import { type Github, getIssueComment } from "./github";
20+
import { findGithubById, getIssueComment } from "./github";
2121
import { getWebServerSettings } from "./web-server-settings";
2222

2323
export type PreviewDeployment = typeof previewDeployments.$inferSelect;
@@ -142,7 +142,17 @@ export const createPreviewDeployment = async (
142142
org?.ownerId || "",
143143
);
144144

145-
const octokit = authGithub(application?.github as Github);
145+
if (!application.githubId) {
146+
throw new TRPCError({
147+
code: "NOT_FOUND",
148+
message: "Github Account not configured correctly",
149+
});
150+
}
151+
152+
// `findApplicationById` redacts `githubPrivateKey` from the `github`
153+
// relation, so the provider must be refetched to authenticate.
154+
const githubProvider = await findGithubById(application.githubId);
155+
const octokit = authGithub(githubProvider);
146156

147157
const runningComment = getIssueComment(
148158
application.name,

0 commit comments

Comments
 (0)