Skip to content

fix(preview-deployment): refetch github provider before authenticating - #4933

Open
CyrilBIENNE wants to merge 1 commit into
Dokploy:canaryfrom
CyrilBIENNE:fix/preview-deployment-github-credentials
Open

fix(preview-deployment): refetch github provider before authenticating#4933
CyrilBIENNE wants to merge 1 commit into
Dokploy:canaryfrom
CyrilBIENNE:fix/preview-deployment-github-credentials

Conversation

@CyrilBIENNE

Copy link
Copy Markdown

findApplicationById redacts githubPrivateKey from the github relation, but createPreviewDeployment passed that redacted object straight to authGithub. Since haveGithubRequirements requires the private key, it always returned false and authGithub threw TRPCError NOT_FOUND: "Github Account not configured correctly".

That throw is uncaught in pages/api/deploy/github.ts, so every pull_request webhook returned a bare 500 and no preview deployment was ever created.

Resolve the provider through findGithubById(application.githubId) instead, matching how every other call site obtains credentials. This keeps the redaction introduced for findApplicationById intact.

Fixes #4898

What is this PR about?

Please describe in a short paragraph what this PR is about.

Checklist

Before submitting this PR, please make sure that:

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. If you have not tested it yet, please do so before submitting. This helps avoid wasting maintainers' time reviewing code that has not been verified by you.

Issues related (if applicable)

closes #123

Screenshots (if applicable)

`findApplicationById` redacts `githubPrivateKey` from the `github`
relation, but `createPreviewDeployment` passed that redacted object
straight to `authGithub`. Since `haveGithubRequirements` requires the
private key, it always returned false and `authGithub` threw
`TRPCError NOT_FOUND: "Github Account not configured correctly"`.

That throw is uncaught in `pages/api/deploy/github.ts`, so every
`pull_request` webhook returned a bare 500 and no preview deployment
was ever created.

Resolve the provider through `findGithubById(application.githubId)`
instead, matching how every other call site obtains credentials. This
keeps the redaction introduced for `findApplicationById` intact.

Fixes Dokploy#4898

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@CyrilBIENNE
CyrilBIENNE requested a review from Siumauricio as a code owner July 29, 2026 11:55
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Jul 29, 2026
@e-novatis

Copy link
Copy Markdown

Confirmed working on a self-hosted Dokploy v0.29.13 instance.

We independently diagnosed the same root cause and applied an equivalent patch: createPreviewDeployment() now reloads the complete GitHub provider with findGithubById(application.githubId) before calling authGithub().

Validated end-to-end with GitHub App authentication:

  • preview created automatically when opening a pull request;
  • same preview updated after each new commit;
  • Dokploy status comment posted on the pull request;
  • isolated preview URL and Smallstep HTTPS certificate generated correctly;
  • preview deployment removed after closing or merging the pull request;
  • production auto-deployment remained functional.

The fix has therefore been exercised against real GitHub webhook events, not only through a unit-level code review.

@ArtuArtaza

Copy link
Copy Markdown

Waiting for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preview deployments fail after v0.29.13 with "Github Account not configured correctly"

3 participants