Skip to content

Commit e694cf6

Browse files
committed
fix: handle unexpected missing token expiry by setting a default
1 parent 8c189a1 commit e694cf6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

gitlab_client.go

+7
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,13 @@ func (gc *gitlabClient) CurrentTokenInfo(ctx context.Context) (et *TokenConfig,
336336
},
337337
UserID: pat.UserID,
338338
}
339+
// Set an artificial expiry date one year after creation if none is set.
340+
// This addresses issue #178 where a token could be issued without an expiry.
341+
// Note: As of GitLab 16.x, all tokens should have an expiry set.
342+
if et.ExpiresAt == nil {
343+
newDate := pat.CreatedAt.AddDate(1, 0, -2)
344+
et.ExpiresAt = &newDate
345+
}
339346
}
340347
return et, err
341348
}

0 commit comments

Comments
 (0)