test: add buildPolicySettings to the db mock in application.real.test.ts - #212
Merged
Merged
Conversation
These five tests have failed on every PR targeting canary since #209 with "Cannot read properties of undefined (reading 'findFirst')". The file mocks @dokploy/server/db with a hand-written query namespace listing only applications, deployHook, domains, patch and member; build-policy reaches db.query.buildPolicySettings on the deploy path, through planApplicationBuild -> resolveBuildPolicy -> previewBuildPolicyDecision -> findBuildPolicySettings (services/build-policy/settings.ts:18). Adds that one namespace. An unstubbed vi.fn() resolves undefined, which findBuildPolicySettings maps to null, which is the policy-off answer, so these tests keep asserting upstream deploy behaviour exactly as they did before #209. Nothing else in build-policy is reachable here: previewBuildPolicyDecision returns before touching exclusions or break-glass when the settings row is absent (resolve.ts:59-72). The four review rounds could not see this. The reviewers compared local failing-test sets against the merge base and they matched, because this same file already failed on their Windows host for an unrelated reason (S/track2/w6-review-2.md:78, "Command failed: mkdir -p C:\"). On Linux CI that problem does not exist and the file fails for the build-policy reason instead.
Member
Author
|
Green. Run 34615190789, job Zero failures, and |
AminDhouib
added a commit
that referenced
this pull request
Sep 11, 2026
…ming Three corrections after #211 and #212 landed on canary. The republish point in section 2.1 was overstated. Step 1 reads the rollback digest off the running service on the host, not off a tag, and a republish adds a GHCR version rather than rewriting the old manifest, so a merge to canary cannot invalidate it. Rewritten to say what actually follows: pin the digest you are rolling to, and keep the docker save, because each republish leaves the previous build untagged and that is what retention sweeps collect. Also records that the fork is in neither Dokploy CSV, so a merge to canary redeploys nothing. Section 3.1 and 3.2 now account for canary having moved twice since b0cadcd. Both follow-ups are runtime-neutral - a CI trigger and a file under __test__ - and either build is a valid rollout target. Section 3.2 now shows how to resolve the current head's digest, and keeps the b0cadcd digest for anyone who would rather roll the reviewed commit and nothing else. Section 5 G6 and section 7 step 0 record that the test regression is fixed: #212 (e92e4ad), run 34615190789, 214 files passed, 2314 passed / 1 skipped / 0 failed.
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.
Fixes the
pr-check (test)failure that has been red on every PR targetingcanarysince #209. One file, one added namespace in a test mock, eleven linesof which nine are the comment.
The failure
Five tests in
apps/dokploy/__test__/deploy/application.real.test.ts:That file mocks
@dokploy/server/dbwith a hand-writtenquerynamespace(
application.real.test.ts:15-53) listingapplications,deployHook,domains,patchandmember. #209 added a deploy-path read ofdb.query.buildPolicySettings, which isundefinedthere.The fifth failure is the same cause wearing a different hat: the TypeError is
raised inside
deployApplication's owntry, so the deployment log came backcarrying
❌ [build-policy] cannot read properties of undefined (reading 'findfirst')where the test expected the deploy's own error text.The fix, and why one namespace is enough
An unstubbed
vi.fn()resolvesundefined;findBuildPolicySettingsmaps thatto
null(settings.ts:21,row ?? null);decideBuildPolicyreads a nullsettings row as policy-off and returns
local/not_enforced(
policy.ts:65-68). So these tests go on asserting the upstream deploybehaviour they asserted before #209, which is what they are for.
Nothing else in the module is reachable from here.
previewBuildPolicyDecisionreturns atresolve.ts:59-72without touchingexclusions or break-glass when the settings row is absent, and
resolveBuildPolicywrites no audit row for alocaldecision. The only otherbuild-policy read of this namespace is
isBuildPolicyEnforcedAnywhere(
settings.ts:52), which the same mock entry would satisfy if a future testreached it.
Evidence this is #209's, not the fork's baseline
Three runs of
pull-request.yml:b0161304, 2026-09-066d27c886, the #209 head merged asb0cadcd3b7e233(#210, docs-only)Why four review rounds missed it
The reviewers ran the suite locally on Windows and compared failing-test sets
against the merge base, which matched exactly in both directions.
S/track2/w6-review-2.md:78lists this same file as item 5 of the files thatalready fail on that host, for an unrelated reason:
Command failed: mkdir -p C:\…. It was red before and after, so a set comparison could not show that #209had changed why it is red. On Linux CI the Windows path problem does not exist
and the build-policy reason surfaces instead.
The general lesson is worth keeping: a local baseline that already fails a file
proves nothing about that file.
Scope
Test-only. No production code, schema, workflow or dependency changes. Context:
#210 and
docs/build-once-rollout-runbook.md§5 G6.