From 979eb1aa0cf10d96d3fb8ee3f7b935e87f32c21b Mon Sep 17 00:00:00 2001 From: Sumit Date: Thu, 20 Jun 2024 18:54:53 +0530 Subject: [PATCH] [Fix] Account Linking UpdateMigrationsByType (#31428) Fix https://github.com/go-gitea/gitea/issues/31427 (cherry picked from commit 17b3a38577d6e1d50ba5565ca3b1f2f57a04bf32) --- services/externalaccount/user.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/services/externalaccount/user.go b/services/externalaccount/user.go index e2de41da18..3cfd8c81f9 100644 --- a/services/externalaccount/user.go +++ b/services/externalaccount/user.go @@ -5,6 +5,7 @@ package externalaccount import ( "context" + "strconv" "strings" "code.gitea.io/gitea/models/auth" @@ -82,6 +83,11 @@ func UpdateExternalUser(ctx context.Context, user *user_model.User, gothUser got // UpdateMigrationsByType updates all migrated repositories' posterid from gitServiceType to replace originalAuthorID to posterID func UpdateMigrationsByType(ctx context.Context, tp structs.GitServiceType, externalUserID string, userID int64) error { + // Skip update if externalUserID is not a valid numeric ID or exceeds int64 + if _, err := strconv.ParseInt(externalUserID, 10, 64); err != nil { + return nil + } + if err := issues_model.UpdateIssuesMigrationsByType(ctx, tp, externalUserID, userID); err != nil { return err }