Skip to content

Commit 6c6a7e7

Browse files
Avoid too long names for actions (#23162) (#23190)
Backport #23162 The name of the job or step comes from the workflow file, while the name of the runner comes from its registration. If the strings used for these names are too long, they could cause db issues. Co-authored-by: Jason Song <i@wolfogre.com>
1 parent 111c509 commit 6c6a7e7

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

models/actions/run.go

+1
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
194194
if len(needs) > 0 {
195195
status = StatusBlocked
196196
}
197+
job.Name, _ = util.SplitStringAtByteN(job.Name, 255)
197198
runJobs = append(runJobs, &ActionRunJob{
198199
RunID: run.ID,
199200
RepoID: run.RepoID,

models/actions/task.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,9 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
298298
if len(workflowJob.Steps) > 0 {
299299
steps := make([]*ActionTaskStep, len(workflowJob.Steps))
300300
for i, v := range workflowJob.Steps {
301+
name, _ := util.SplitStringAtByteN(v.String(), 255)
301302
steps[i] = &ActionTaskStep{
302-
Name: v.String(),
303+
Name: name,
303304
TaskID: task.ID,
304305
Index: int64(i),
305306
RepoID: task.RepoID,

routers/api/actions/runner/runner.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"code.gitea.io/gitea/modules/actions"
1313
"code.gitea.io/gitea/modules/json"
1414
"code.gitea.io/gitea/modules/log"
15+
"code.gitea.io/gitea/modules/util"
1516
actions_service "code.gitea.io/gitea/services/actions"
1617

1718
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
@@ -55,9 +56,10 @@ func (s *Service) Register(
5556
}
5657

5758
// create new runner
59+
name, _ := util.SplitStringAtByteN(req.Msg.Name, 255)
5860
runner := &actions_model.ActionRunner{
5961
UUID: gouuid.New().String(),
60-
Name: req.Msg.Name,
62+
Name: name,
6163
OwnerID: runnerToken.OwnerID,
6264
RepoID: runnerToken.RepoID,
6365
AgentLabels: req.Msg.AgentLabels,

0 commit comments

Comments
 (0)