limit text size for PRs in the migrator (#2662)

* limit text size for PRs in the migrator
This commit is contained in:
Marko Gaćeša 2024-09-05 15:00:41 +00:00 committed by Harness
parent 1c8a47636f
commit d96ee12399

View File

@ -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,