Compare commits

...

4 Commits

Author SHA1 Message Date
autofix-ci[bot] 3e2eb7213d [autofix.ci] apply automated fixes 2026-04-05 19:41:38 +00:00
Mauricio Siu dcb95374da fix: also collect added/removed paths and filter nullish values
commit.modified can be undefined causing micromatch to throw
"Expected input to be a string". Also includes added and removed
paths from commits so watch paths can match against all changed files.
2026-04-05 13:41:17 -06:00
autofix-ci[bot] 36e131cf12 [autofix.ci] apply automated fixes 2026-04-05 19:38:19 +00:00
Mauricio Siu 17b4c0fc58 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
2026-04-05 13:37:44 -06:00
2 changed files with 56 additions and 21 deletions
@@ -53,9 +53,14 @@ 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 || []),
...(commit.added || []),
...(commit.removed || []),
])
.filter(Boolean) || [];
const shouldDeployPaths = shouldDeploy(
composeResult.watchPaths,
@@ -73,9 +78,14 @@ 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 || []),
...(commit.added || []),
...(commit.removed || []),
])
.filter(Boolean) || [];
const shouldDeployPaths = shouldDeploy(
composeResult.watchPaths,
@@ -124,17 +134,32 @@ 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 || []),
...(commit.added || []),
...(commit.removed || []),
])
.filter(Boolean) || [];
} else if (provider === "gitlab") {
normalizedCommits = req.body?.commits?.flatMap(
(commit: any) => commit.modified,
);
normalizedCommits =
req.body?.commits
?.flatMap((commit: any) => [
...(commit.modified || []),
...(commit.added || []),
...(commit.removed || []),
])
.filter(Boolean) || [];
} else if (provider === "gitea") {
normalizedCommits = req.body?.commits?.flatMap(
(commit: any) => commit.modified,
);
normalizedCommits =
req.body?.commits
?.flatMap((commit: any) => [
...(commit.modified || []),
...(commit.added || []),
...(commit.removed || []),
])
.filter(Boolean) || [];
}
const shouldDeployPaths = shouldDeploy(
@@ -149,9 +174,14 @@ 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 || []),
...(commit.added || []),
...(commit.removed || []),
])
.filter(Boolean) || [];
const shouldDeployPaths = shouldDeploy(
composeResult.watchPaths,
+8 -3
View File
@@ -213,9 +213,14 @@ 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 || []),
...(commit.added || []),
...(commit.removed || []),
])
.filter(Boolean) || [];
const apps = await db.query.applications.findMany({
where: and(