You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
On a Bitbucket Cloud git source (private deploy key over SSH, no Git App), a manual / non-webhook redeploy of a pull-request preview silently rebuilds the application's base branch (e.g. develop) instead of the PR's code. The deployment is marked successful, so the preview ends up running the wrong code with no error.
Webhook-triggered PR deploys work correctly (they carry pullrequest.source.commit.hash). The problem is specifically a manual redeploy of an existing preview — clicking Redeploy in the UI, or calling the deploy API with ?pr=<id> without a webhook.
Expected
A manual redeploy of a PR preview rebuilds the PR's code (the same commit the webhook used), or fails loudly. It should not silently build the base branch.
Actual
commit = HEAD. Coolify tries to resolve the PR commit via git ls-remote origin pull/<id>/head, which does not exist on Bitbucket Cloud (Bitbucket Cloud exposes no PR refs over git — neither pull/N/head nor refs/pull-requests/N/from). The commit stays HEAD, so Coolify clones -b <base-branch> and checks out HEAD -> it builds the base branch. Green deployment, wrong code.
Relevant log (redacted)
Importing <repo>.git:develop (commit sha HEAD) to /artifacts/<uuid>.
Checking out tag pull/<id>/head.
git clone --recurse-submodules -b 'develop' ... && ... git checkout 'HEAD'
Your branch is up to date with 'origin/develop'.
Root cause
The Bitbucket webhook deploy passes commit = pullrequest.source.commit.hash, so it checks out the right commit.
A manual redeploy has no such commit. ApplicationDeploymentJob computes lsRemoteRef = "pull/<id>/head" (no bitbucket-specific PR ref in that switch) and runs git ls-remote origin pull/<id>/head. On Bitbucket Cloud this resolves to nothing, so commit stays HEAD and the base branch is built.
Suggested fix
Persist the PR's resolved source commit on the preview and reuse it for manual redeploys; or
For Bitbucket, resolve the PR head via the Bitbucket API at redeploy time (the source branch name is known) and fail loudly if it cannot be resolved, instead of silently building the base branch.
Note
This is distinct from #9926, which is a hard failure on webhook deploys with shallow clone enabled (worked around by disabling shallow clone). Here shallow clone is off and webhook deploys succeed; the manual redeploy is a separate, silent failure.
Open a pull request against develop. The webhook creates a preview and builds the PR commit correctly (verify the PR code is live).
Manually click Redeploy on that preview in the UI (or call the deploy API with ?pr=<id> without a webhook).
Observe: the deployment log shows Importing ...:develop (commit sha HEAD) and git checkout 'HEAD', the deployment is marked successful, but the preview now runs develop instead of the PR code.
Error Message and Logs
Summary
On a Bitbucket Cloud git source (private deploy key over SSH, no Git App), a manual / non-webhook redeploy of a pull-request preview silently rebuilds the application's base branch (e.g.
develop) instead of the PR's code. The deployment is marked successful, so the preview ends up running the wrong code with no error.Webhook-triggered PR deploys work correctly (they carry
pullrequest.source.commit.hash). The problem is specifically a manual redeploy of an existing preview — clicking Redeploy in the UI, or calling the deploy API with?pr=<id>without a webhook.Expected
A manual redeploy of a PR preview rebuilds the PR's code (the same commit the webhook used), or fails loudly. It should not silently build the base branch.
Actual
commit = HEAD. Coolify tries to resolve the PR commit viagit ls-remote origin pull/<id>/head, which does not exist on Bitbucket Cloud (Bitbucket Cloud exposes no PR refs over git — neitherpull/N/headnorrefs/pull-requests/N/from). The commit staysHEAD, so Coolify clones-b <base-branch>and checks outHEAD-> it builds the base branch. Green deployment, wrong code.Relevant log (redacted)
Root cause
commit = pullrequest.source.commit.hash, so it checks out the right commit.ApplicationDeploymentJobcomputeslsRemoteRef = "pull/<id>/head"(no bitbucket-specific PR ref in that switch) and runsgit ls-remote origin pull/<id>/head. On Bitbucket Cloud this resolves to nothing, socommitstaysHEADand the base branch is built.Suggested fix
Note
This is distinct from #9926, which is a hard failure on webhook deploys with shallow clone enabled (worked around by disabling shallow clone). Here shallow clone is off and webhook deploys succeed; the manual redeploy is a separate, silent failure.
Version: Coolify v4.1.2 (self-hosted).
Steps to Reproduce
develop, with preview deployments enabled. Make sure Shallow Clone is OFF (so this is not [Bug]: Bitbucket preview deployments fail because Coolify tries to fetch a existing short commit ref #9926).develop. The webhook creates a preview and builds the PR commit correctly (verify the PR code is live).?pr=<id>without a webhook).Importing ...:develop (commit sha HEAD)andgit checkout 'HEAD', the deployment is marked successful, but the preview now runsdevelopinstead of the PR code.Example Repository URL
No response
Coolify Version
4.1.2
Are you using Coolify Cloud?
No (self-hosted)
Operating System and Version (self-hosted)
No response
Additional Information
No response