From 4e45baa683b77fbc543cc9e66781e7feab0950f8 Mon Sep 17 00:00:00 2001 From: Eury Sosa Garcia <112292926+watercubz@users.noreply.github.com> Date: Tue, 12 May 2026 20:53:27 -0400 Subject: [PATCH] refactor: gitLab callback to improve type handling the type assertion was removed; the `findGitlabById` function only accepts string type, so making an assertion causes type redundancy and reduces type safety. similarly, the case is being handled where `result.expires_in` for some reason comes out empty, null or undefined or any other type that is not the expected one, and an exception is called in the case that an unexpected value arrives. --- apps/dokploy/pages/api/providers/gitlab/callback.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/dokploy/pages/api/providers/gitlab/callback.ts b/apps/dokploy/pages/api/providers/gitlab/callback.ts index 42d81df12e..975d53d1c6 100644 --- a/apps/dokploy/pages/api/providers/gitlab/callback.ts +++ b/apps/dokploy/pages/api/providers/gitlab/callback.ts @@ -11,7 +11,7 @@ export default async function handler( return res.status(400).json({ error: "Missing or invalid code" }); } - const gitlab = await findGitlabById(gitlabId as string); + const gitlab = await findGitlabById(gitlabId); // Use internal URL for token exchange when GitLab is on same instance as Dokploy const baseUrl = gitlab.gitlabInternalUrl || gitlab.gitlabUrl; const gitlabUrl = new URL(baseUrl); @@ -39,9 +39,9 @@ export default async function handler( method: "POST", headers, body: new URLSearchParams({ - client_id: gitlab.applicationId as string, - client_secret: gitlab.secret as string, - code: code as string, + client_id: gitlab.applicationId, + client_secret: gitlab.secret, + code: code, grant_type: "authorization_code", redirect_uri: `${gitlab.redirectUri}?gitlabId=${gitlabId}`, }), @@ -53,7 +53,7 @@ export default async function handler( return res.status(400).json({ error: "Missing or invalid code" }); } - const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in; + const expiresAt = result.expires_in ? Math.floor(Date.now() / 1000) + result.expires_in : `Error receiving expires_in, expected type: number, but currently received: ${result.expires_in}`; await updateGitlab(gitlab.gitlabId, { accessToken: result.access_token, refreshToken: result.refresh_token,