Skip to content

Commit fc5b8d0

Browse files
committed
fix(gitlab): handle missing expires_in in OAuth token response
Some self-hosted GitLab instances (e.g. older versions without expires_in configured in doorkeeper) omit expires_in from the OAuth token response. Computing Date.now()/1000 + undefined produced NaN, which Postgres rejected on the expires_at integer column, crashing both the initial OAuth callback and the token refresh flow with a 500. Falls back to null when expires_in is absent, matching the existing Gitea callback behavior. Closes Dokploy#4362
1 parent 1183c7c commit fc5b8d0

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎apps/dokploy/pages/api/providers/gitlab/callback.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ export default async function handler(
5353
return res.status(400).json({ error: "Missing or invalid code" });
5454
}
5555

56-
const expiresAt = Math.floor(Date.now() / 1000) + result.expires_in;
56+
const expiresAt = result.expires_in
57+
? Math.floor(Date.now() / 1000) + result.expires_in
58+
: null;
5759
await updateGitlab(gitlab.gitlabId, {
5860
accessToken: result.access_token,
5961
refreshToken: result.refresh_token,

‎packages/server/src/utils/providers/gitlab.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ export const refreshGitlabToken = async (gitlabProviderId: string) => {
4444

4545
const data = await response.json();
4646

47-
const expiresAt = Math.floor(Date.now() / 1000) + data.expires_in;
47+
const expiresAt = data.expires_in
48+
? Math.floor(Date.now() / 1000) + data.expires_in
49+
: null;
4850

4951
await updateGitlab(gitlabProviderId, {
5052
accessToken: data.access_token,

0 commit comments

Comments
 (0)