mirror of
https://github.com/andwati/dokploy.git
synced 2026-10-28 07:52:14 +00:00
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 #4898 Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 5
parent
5df820a740
commit
30e8d9b86e
@@ -17,7 +17,7 @@ import { manageDomain } from "../utils/traefik/domain";
|
|||||||
import { findApplicationById } from "./application";
|
import { findApplicationById } from "./application";
|
||||||
import { removeDeploymentsByPreviewDeploymentId } from "./deployment";
|
import { removeDeploymentsByPreviewDeploymentId } from "./deployment";
|
||||||
import { createDomain } from "./domain";
|
import { createDomain } from "./domain";
|
||||||
import { type Github, getIssueComment } from "./github";
|
import { findGithubById, getIssueComment } from "./github";
|
||||||
import { getWebServerSettings } from "./web-server-settings";
|
import { getWebServerSettings } from "./web-server-settings";
|
||||||
|
|
||||||
export type PreviewDeployment = typeof previewDeployments.$inferSelect;
|
export type PreviewDeployment = typeof previewDeployments.$inferSelect;
|
||||||
@@ -142,7 +142,17 @@ export const createPreviewDeployment = async (
|
|||||||
org?.ownerId || "",
|
org?.ownerId || "",
|
||||||
);
|
);
|
||||||
|
|
||||||
const octokit = authGithub(application?.github as Github);
|
if (!application.githubId) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "NOT_FOUND",
|
||||||
|
message: "Github Account not configured correctly",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// `findApplicationById` redacts `githubPrivateKey` from the `github`
|
||||||
|
// relation, so the provider must be refetched to authenticate.
|
||||||
|
const githubProvider = await findGithubById(application.githubId);
|
||||||
|
const octokit = authGithub(githubProvider);
|
||||||
|
|
||||||
const runningComment = getIssueComment(
|
const runningComment = getIssueComment(
|
||||||
application.name,
|
application.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user