@@ -21,6 +21,7 @@ import (
2121 "code.gitea.io/gitea/modules/references"
2222 api "code.gitea.io/gitea/modules/structs"
2323 "code.gitea.io/gitea/modules/timeutil"
24+ "code.gitea.io/gitea/modules/util"
2425
2526 "xorm.io/builder"
2627)
@@ -138,6 +139,7 @@ func ChangeIssueTitle(ctx context.Context, issue *Issue, doer *user_model.User,
138139 }
139140 defer committer .Close ()
140141
142+ issue .Title , _ = util .SplitStringAtByteN (issue .Title , 255 )
141143 if err = UpdateIssueCols (ctx , issue , "name" ); err != nil {
142144 return fmt .Errorf ("updateIssueCols: %w" , err )
143145 }
@@ -386,6 +388,7 @@ func NewIssueWithIndex(ctx context.Context, doer *user_model.User, opts NewIssue
386388}
387389
388390// NewIssue creates new issue with labels for repository.
391+ // The title will be cut off at 255 characters if it's longer than 255 characters.
389392func NewIssue (ctx context.Context , repo * repo_model.Repository , issue * Issue , labelIDs []int64 , uuids []string ) (err error ) {
390393 ctx , committer , err := db .TxContext (ctx )
391394 if err != nil {
@@ -399,6 +402,7 @@ func NewIssue(ctx context.Context, repo *repo_model.Repository, issue *Issue, la
399402 }
400403
401404 issue .Index = idx
405+ issue .Title , _ = util .SplitStringAtByteN (issue .Title , 255 )
402406
403407 if err = NewIssueWithIndex (ctx , issue .Poster , NewIssueOptions {
404408 Repo : repo ,
0 commit comments