From 26cae3b8a99b282c861feb7e99cda71ab35c96bb Mon Sep 17 00:00:00 2001 From: Mauricio Siu Date: Sun, 19 Jul 2026 21:04:54 -0600 Subject: [PATCH] fix(types): guard git-provider access check for optional id in getBranches The getBranches inputs type the provider id as optional, so only fetch and authorize when an id is actually present; the underlying getBranches already returns [] when no id is supplied. --- apps/dokploy/server/api/routers/bitbucket.ts | 6 ++++-- apps/dokploy/server/api/routers/github.ts | 6 ++++-- apps/dokploy/server/api/routers/gitlab.ts | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/dokploy/server/api/routers/bitbucket.ts b/apps/dokploy/server/api/routers/bitbucket.ts index c5a7e41a1..be1437cbd 100644 --- a/apps/dokploy/server/api/routers/bitbucket.ts +++ b/apps/dokploy/server/api/routers/bitbucket.ts @@ -89,8 +89,10 @@ export const bitbucketRouter = createTRPCRouter({ getBitbucketBranches: protectedProcedure .input(apiFindBitbucketBranches) .query(async ({ input, ctx }) => { - const bitbucket = await findBitbucketById(input.bitbucketId); - await assertGitProviderAccess(ctx.session, bitbucket.gitProvider); + if (input.bitbucketId) { + const bitbucket = await findBitbucketById(input.bitbucketId); + await assertGitProviderAccess(ctx.session, bitbucket.gitProvider); + } return await getBitbucketBranches(input); }), testConnection: protectedProcedure diff --git a/apps/dokploy/server/api/routers/github.ts b/apps/dokploy/server/api/routers/github.ts index d27388863..733cc2b83 100644 --- a/apps/dokploy/server/api/routers/github.ts +++ b/apps/dokploy/server/api/routers/github.ts @@ -40,8 +40,10 @@ export const githubRouter = createTRPCRouter({ getGithubBranches: protectedProcedure .input(apiFindGithubBranches) .query(async ({ input, ctx }) => { - const github = await findGithubById(input.githubId); - await assertGitProviderAccess(ctx.session, github.gitProvider); + if (input.githubId) { + const github = await findGithubById(input.githubId); + await assertGitProviderAccess(ctx.session, github.gitProvider); + } return await getGithubBranches(input); }), githubProviders: protectedProcedure.query(async ({ ctx }) => { diff --git a/apps/dokploy/server/api/routers/gitlab.ts b/apps/dokploy/server/api/routers/gitlab.ts index 76b4cd16d..c93637bd1 100644 --- a/apps/dokploy/server/api/routers/gitlab.ts +++ b/apps/dokploy/server/api/routers/gitlab.ts @@ -100,8 +100,10 @@ export const gitlabRouter = createTRPCRouter({ getGitlabBranches: protectedProcedure .input(apiFindGitlabBranches) .query(async ({ input, ctx }) => { - const gitlab = await findGitlabById(input.gitlabId); - await assertGitProviderAccess(ctx.session, gitlab.gitProvider); + if (input.gitlabId) { + const gitlab = await findGitlabById(input.gitlabId); + await assertGitProviderAccess(ctx.session, gitlab.gitProvider); + } return await getGitlabBranches(input); }), testConnection: protectedProcedure