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,