mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-15 20:25:23 +02:00
fix: webhook crash when commits array is missing and watch paths enabled
When a GitHub webhook fires with undefined commits and watch paths are configured, flatMap on undefined crashes the handler. Default to empty array so shouldDeploy can handle it gracefully. Closes #4081
This commit is contained in:
@@ -53,9 +53,10 @@ export default async function handler(
|
||||
|
||||
if (sourceType === "github") {
|
||||
const branchName = extractBranchName(req.headers, req.body);
|
||||
const normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits =
|
||||
req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
) || [];
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
composeResult.watchPaths,
|
||||
@@ -73,9 +74,10 @@ export default async function handler(
|
||||
}
|
||||
} else if (sourceType === "gitlab") {
|
||||
const branchName = extractBranchName(req.headers, req.body);
|
||||
const normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits =
|
||||
req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
) || [];
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
composeResult.watchPaths,
|
||||
@@ -124,17 +126,20 @@ export default async function handler(
|
||||
let normalizedCommits: string[] = [];
|
||||
|
||||
if (provider === "github") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits =
|
||||
req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
) || [];
|
||||
} else if (provider === "gitlab") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits =
|
||||
req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
) || [];
|
||||
} else if (provider === "gitea") {
|
||||
normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
normalizedCommits =
|
||||
req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
) || [];
|
||||
}
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
@@ -149,9 +154,10 @@ export default async function handler(
|
||||
} else if (sourceType === "gitea") {
|
||||
const branchName = extractBranchName(req.headers, req.body);
|
||||
|
||||
const normalizedCommits = req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits =
|
||||
req.body?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
) || [];
|
||||
|
||||
const shouldDeployPaths = shouldDeploy(
|
||||
composeResult.watchPaths,
|
||||
|
||||
@@ -213,9 +213,10 @@ export default async function handler(
|
||||
const deploymentTitle = extractCommitMessage(req.headers, req.body);
|
||||
const deploymentHash = extractHash(req.headers, req.body);
|
||||
const owner = githubBody?.repository?.owner?.name;
|
||||
const normalizedCommits = githubBody?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
);
|
||||
const normalizedCommits =
|
||||
githubBody?.commits?.flatMap(
|
||||
(commit: any) => commit.modified,
|
||||
) || [];
|
||||
|
||||
const apps = await db.query.applications.findMany({
|
||||
where: and(
|
||||
|
||||
Reference in New Issue
Block a user