mirror of
https://github.com/go-gitea/gitea.git
synced 2026-09-08 22:13:26 +09:00
fix(actions): prevent panic when workflow contains null jobs (#37570)
## The issue Closes #37568. Basically due to empty fields being present in the actions file, the jobs would be produced as `nil` inside `jobparser.go` . Because of this when we call `Parse` on the `jobparser` module. ```go Needs: job.Needs(), ``` would propagate the `nil` job down the chain. ## The fix For now i decide to fix it by guarding with an `if job == nil` check. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
co-authored by
wxiaoguang
Lunny Xiao
Giteabot
parent
cf48aa0188
commit
630258410d
@@ -31,6 +31,9 @@ func Parse(content []byte, options ...ParseOption) ([]*SingleWorkflow, error) {
|
||||
}
|
||||
results := map[string]*JobResult{}
|
||||
for id, job := range origin.Jobs {
|
||||
if job == nil {
|
||||
return nil, fmt.Errorf("needed job not found: %q", id)
|
||||
}
|
||||
results[id] = &JobResult{
|
||||
Needs: job.Needs(),
|
||||
Result: pc.jobResults[id],
|
||||
|
||||
Reference in New Issue
Block a user