From d96ee12399ad70ea2872e5018e0bb0b31f3d6ca1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Ga=C4=87e=C5=A1a?= Date: Thu, 5 Sep 2024 15:00:41 +0000 Subject: [PATCH] limit text size for PRs in the migrator (#2662) * limit text size for PRs in the migrator --- app/services/migrate/pullreq.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/services/migrate/pullreq.go b/app/services/migrate/pullreq.go index 0d4287bcd..379c0f55b 100644 --- a/app/services/migrate/pullreq.go +++ b/app/services/migrate/pullreq.go @@ -222,6 +222,15 @@ func (r *repoImportState) convertPullReq( createdAt := timestampMillis(extPullReq.Created, now) updatedAt := timestampMillis(extPullReq.Updated, now) + const maxTitleLen = 256 + const maxDescriptionLen = 100000 // This limit is deliberately higher than the limit in our API. + if len(extPullReq.Title) > maxTitleLen { + extPullReq.Title = extPullReq.Title[:maxTitleLen] + } + if len(extPullReq.Body) > maxDescriptionLen { + extPullReq.Body = extPullReq.Body[:maxDescriptionLen] + } + pr := &types.PullReq{ ID: 0, // the ID will be populated in the data layer Version: 0, @@ -400,6 +409,11 @@ func (r *repoImportState) createComment( resolvedBy = &commenter.ID } + const maxLenText = 64 << 10 // This limit is deliberately larger than the limit in our API. + if len(extComment.Body) > maxLenText { + extComment.Body = extComment.Body[:maxLenText] + } + comment := &types.PullReqActivity{ CreatedBy: commenter.ID, Created: commentedAt,