From 4270eca5972bc4898b65451c294c1b9b0ad6f9af Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Tue, 5 Nov 2024 14:51:12 +0100 Subject: [PATCH] gitea: add check if pull_request webhook is missing pull info (#4305) --- server/forge/gitea/parse.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/forge/gitea/parse.go b/server/forge/gitea/parse.go index a8856a611..7b2629b2e 100644 --- a/server/forge/gitea/parse.go +++ b/server/forge/gitea/parse.go @@ -16,6 +16,7 @@ package gitea import ( + "fmt" "io" "net/http" "strings" @@ -111,6 +112,11 @@ func parsePullRequestHook(payload io.Reader) (*model.Repo, *model.Pipeline, erro return nil, nil, err } + if pr.PullRequest == nil { + // this should never have happened but it did - so we check + return nil, nil, fmt.Errorf("parsed pull_request webhook does not contain pull_request info") + } + // Don't trigger pipelines for non-code changes ... if pr.Action != actionOpen && pr.Action != actionSync && pr.Action != actionClose { log.Debug().Msgf("pull_request action is '%s' and no open or sync", pr.Action)