aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2023-02-28 18:20:36 +0800
committerGitHub <noreply@github.com>2023-02-28 18:20:36 +0800
commitcbc9a0fe477b1b8af249ca0b8dac5fc2be64e9f6 (patch)
treecca5804520e6fcc5bfb3d388932743331fde3096
parent067b0c2664d127c552ccdfd264257caca4907a77 (diff)
downloadgitea-cbc9a0fe477b1b8af249ca0b8dac5fc2be64e9f6.tar.gz
gitea-cbc9a0fe477b1b8af249ca0b8dac5fc2be64e9f6.zip
Avoid too long names for actions (#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.
-rw-r--r--models/actions/run.go1
-rw-r--r--models/actions/task.go3
-rw-r--r--routers/api/actions/runner/runner.go4
3 files changed, 6 insertions, 2 deletions
diff --git a/models/actions/run.go b/models/actions/run.go
index a8d991471e..d5ab45a519 100644
--- a/models/actions/run.go
+++ b/models/actions/run.go
@@ -192,6 +192,7 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
if len(needs) > 0 || run.NeedApproval {
status = StatusBlocked
}
+ job.Name, _ = util.SplitStringAtByteN(job.Name, 255)
runJobs = append(runJobs, &ActionRunJob{
RunID: run.ID,
RepoID: run.RepoID,
diff --git a/models/actions/task.go b/models/actions/task.go
index 5b6206c346..ffec4c92aa 100644
--- a/models/actions/task.go
+++ b/models/actions/task.go
@@ -298,8 +298,9 @@ func CreateTaskForRunner(ctx context.Context, runner *ActionRunner) (*ActionTask
if len(workflowJob.Steps) > 0 {
steps := make([]*ActionTaskStep, len(workflowJob.Steps))
for i, v := range workflowJob.Steps {
+ name, _ := util.SplitStringAtByteN(v.String(), 255)
steps[i] = &ActionTaskStep{
- Name: v.String(),
+ Name: name,
TaskID: task.ID,
Index: int64(i),
RepoID: task.RepoID,
diff --git a/routers/api/actions/runner/runner.go b/routers/api/actions/runner/runner.go
index 7dbab9da0a..d0bfb2363e 100644
--- a/routers/api/actions/runner/runner.go
+++ b/routers/api/actions/runner/runner.go
@@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/modules/actions"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
+ "code.gitea.io/gitea/modules/util"
actions_service "code.gitea.io/gitea/services/actions"
runnerv1 "code.gitea.io/actions-proto-go/runner/v1"
@@ -55,9 +56,10 @@ func (s *Service) Register(
}
// create new runner
+ name, _ := util.SplitStringAtByteN(req.Msg.Name, 255)
runner := &actions_model.ActionRunner{
UUID: gouuid.New().String(),
- Name: req.Msg.Name,
+ Name: name,
OwnerID: runnerToken.OwnerID,
RepoID: runnerToken.RepoID,
AgentLabels: req.Msg.AgentLabels,