fix(webhooks): normalize watch path changed-file matching#4085
Open
jakvbs wants to merge 2 commits intoDokploy:canaryfrom
Open
fix(webhooks): normalize watch path changed-file matching#4085jakvbs wants to merge 2 commits intoDokploy:canaryfrom
jakvbs wants to merge 2 commits intoDokploy:canaryfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is this PR about?
This PR fixes a crash in Dokploy webhook-driven auto-deploys when Watch Paths are enabled and the incoming webhook payload contains missing or partial changed-file arrays. It makes watch path evaluation defensive against nullish file lists and normalizes changed files across
added,modified, andremovedentries before matching.Checklist
Before submitting this PR, please make sure that:
canarybranch.Issues related (if applicable)
Closes #4081
Screenshots (if applicable)
N/A
Additional notes
What changed
shouldDeploy()returnfalseinstead of throwing when the changed-file list is missing or contains only nullish valuesnormalizeChangedFilesFromCommits()to mergeadded,modified, andremovedpaths and filter invalid entriesHow this was tested
pnpm installcp apps/dokploy/.env.example apps/dokploy/.envpnpm run dokploy:setuppnpm run server:scriptpnpm run dokploy:devhttp://127.0.0.1:3000with redirect to/registerpnpm exec vitest run __test__/deploy/watch-paths.test.ts __test__/deploy/normalize-changed-files.test.ts --config __test__/vitest.config.tsEnvironment note
24.4.0SDKROOT=$(xcrun --show-sdk-path)CPLUS_INCLUDE_PATH=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1Greptile Summary
This PR fixes a crash in Dokploy's webhook-driven auto-deploy when Watch Paths are configured and the incoming payload contains a missing or partial
commitsarray. It introducesnormalizeChangedFilesFromCommits()to safely mergeadded,modified, andremovedfile paths from each commit while filtering out null/undefined/empty entries, updatesshouldDeploy()to be null-safe (returningfalseinstead of crashing on missing file lists), and applies both changes across all webhook handlers (GitHub, GitLab, Gitea, soft-serve, and Compose variants).Key changes:
normalizeChangedFilesFromCommits()utility inpackages/server/src/utils/watch-paths/normalize-changed-files.tsthat defensively aggregates all three file-change buckets per commitshouldDeploy()updated to acceptnull | undefinedinput and returnfalsefor empty normalized file lists instead of passingundefinedtomicromatch.some()flatMap((c) => c.modified)pattern to the new utility — this also broadens watch-path matching to includeaddedandremovedfiles (intentional, correct behavior)Confidence Score: 5/5
Safe to merge — the fix is narrowly scoped, well-tested, and only changes crash behavior to a safe default of skipping the deploy.
All changes are defensive null-safety improvements with no logic regressions. The only semantic change beyond the crash fix (now including added/removed files in watch-path matching) is intentional, documented, and correct. Tests cover the key regression scenarios.
No files require special attention.
Important Files Changed
Reviews (1): Last reviewed commit: "fix(webhooks): normalize changed file pa..." | Re-trigger Greptile
(5/5) You can turn off certain types of comments like style here!