Repository: openshift-pipelines/pipelines-as-code (go)

Issue:
a lot of "skips processing event"  in the logs

there is a " skips processing event !" with no context in the logs lately.. they are a bit worthless if there is no context why it was skipped... so either we skip showing them or add more info about it

![image](https://user-images.githubusercontent.com/98980/165060861-f191ed6a-f6e2-42a6-ad91-734a0fb410fd.png)


Pull request:
Give better reasons when not detecting payload
We were just speaking skip event, we now explains why.

Closes #626

Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com><!-- 🎉🎉🎉 Thank you for the PR!!! 🎉🎉🎉 -->

# Changes

<!-- Describe your changes here- ideally you can get that description straight from
your descriptive commit message(s)! -->

# Submitter Checklist

- [ ] ♽  Run `make test lint` before submitting a PR (ie: with [pre-commit](https://pipelinesascode.com/dev/tools), no need to waste CPU cycle on CI
- [ ] 📖 If you are adding a user facing feature or make a change of the behavior, please verify that you have documented it
- [ ] 🧪 100% coverage is not a target but most of the time we would rather have a unit test if you make a code change.
- [ ] 🎁 If that's something that is possible to do please ensure to check if we can add a e2e test.
- [ ] 🔎 If there is a flakiness in the CI tests then don't *necessary* ignore it, better get the flakyness fixed before merging or if that's not possible there is a good reason to bypass it. (token rate limitation may be a good reason to skip).


Patch:
diff --git a/Makefile b/Makefile
index ad0c0437..ac62daee 100644
--- a/Makefile
+++ b/Makefile
@@ -136,7 +136,7 @@ fmt:
 
 .PHONY: fumpt ## formats the GO code with gofumpt(excludes vendors dir)
 fumpt:
-	@$(GOFUMPT) -w test/*/*/*go test/*go
+	@find test pkg -name '*.go'|xargs -P4 $(GOFUMPT) -w
 
 .PHONY: help
 help: ## print this help
diff --git a/pkg/adapter/adapter.go b/pkg/adapter/adapter.go
index e962a6ca..3ae08552 100644
--- a/pkg/adapter/adapter.go
+++ b/pkg/adapter/adapter.go
@@ -55,7 +55,7 @@ func New(run *params.Run, k *kubeinteraction.Interaction) adapter.AdapterConstru
 	}
 }
 
-func (l *listener) Start(ctx context.Context) error {
+func (l *listener) Start(_ context.Context) error {
 	l.logger.Infof("Starting Pipelines as Code version: %s", version.Version)
 
 	mux := http.NewServeMux()
@@ -63,7 +63,7 @@ func (l *listener) Start(ctx context.Context) error {
 	// for handling probes
 	mux.HandleFunc("/live", func(w http.ResponseWriter, r *http.Request) {
 		w.WriteHeader(200)
-		fmt.Fprint(w, "ok")
+		_, _ = fmt.Fprint(w, "ok")
 	})
 
 	mux.HandleFunc("/", l.handleEvent())
@@ -139,7 +139,9 @@ func (l listener) handleEvent() http.HandlerFunc {
 func (l listener) detectProvider(reqHeader *http.Header, reqBody string) (provider.Interface, *zap.SugaredLogger, error) {
 	log := *l.logger
 
-	processRes := func(processEvent bool, provider provider.Interface, logger *zap.SugaredLogger, err error) (provider.Interface, *zap.SugaredLogger, error) {
+	processRes := func(processEvent bool, provider provider.Interface, logger *zap.SugaredLogger, skipReason string,
+		err error,
+	) (provider.Interface, *zap.SugaredLogger, error) {
 		if processEvent {
 			provider.SetLogger(logger)
 			return provider, logger, nil
@@ -149,35 +151,38 @@ func (l listener) detectProvider(reqHeader *http.Header, reqBody string) (provid
 			logger.Error(errStr)
 			return nil, logger, fmt.Errorf(errStr)
 		}
-		logger.Info("skips processing event !")
-		return nil, logger, fmt.Errorf("skips processing event")
+
+		if skipReason != "" {
+			logger.Infof("skipping event: %s", skipReason)
+		}
+		return nil, logger, fmt.Errorf("skipping event")
 	}
 
 	gitHub := &github.Provider{CheckRunIDS: &sync.Map{}}
-	isGH, processReq, logger, err := gitHub.Detect(reqHeader, reqBody, &log)
+	isGH, processReq, logger, reason, err := gitHub.Detect(reqHeader, reqBody, &log)
 	if isGH {
-		return processRes(processReq, gitHub, logger, err)
+		return processRes(processReq, gitHub, logger, reason, err)
 	}
 
 	bitServer := &bitbucketserver.Provider{}
-	isBitServer, processReq, logger, err := bitServer.Detect(reqHeader, reqBody, &log)
+	isBitServer, processReq, logger, reason, err := bitServer.Detect(reqHeader, reqBody, &log)
 	if isBitServer {
-		return processRes(processReq, bitServer, logger, err)
+		return processRes(processReq, bitServer, logger, reason, err)
 	}
 
 	gitLab := &gitlab.Provider{}
-	isGitlab, processReq, logger, err := gitLab.Detect(reqHeader, reqBody, &log)
+	isGitlab, processReq, logger, reason, err := gitLab.Detect(reqHeader, reqBody, &log)
 	if isGitlab {
-		return processRes(processReq, gitLab, logger, err)
+		return processRes(processReq, gitLab, logger, reason, err)
 	}
 
 	bitCloud := &bitbucketcloud.Provider{}
-	isBitCloud, processReq, logger, err := bitCloud.Detect(reqHeader, reqBody, &log)
+	isBitCloud, processReq, logger, reason, err := bitCloud.Detect(reqHeader, reqBody, &log)
 	if isBitCloud {
-		return processRes(processReq, bitCloud, logger, err)
+		return processRes(processReq, bitCloud, logger, reason, err)
 	}
 
-	return processRes(false, nil, logger, fmt.Errorf("no supported Git Provider is detected"))
+	return processRes(false, nil, logger, "", fmt.Errorf("no supported Git provider has been detected"))
 }
 
 func (l listener) writeResponse(response http.ResponseWriter, statusCode int, message string) {
diff --git a/pkg/provider/bitbucketcloud/events.go b/pkg/provider/bitbucketcloud/events.go
index 8cc844d3..dcaa7371 100644
--- a/pkg/provider/bitbucketcloud/events.go
+++ b/pkg/provider/bitbucketcloud/events.go
@@ -77,7 +77,9 @@ func parsePayloadType(event string, rawPayload string) (interface{}, error) {
 
 	var localEvent string
 	if strings.HasPrefix(event, "pullrequest:") {
-		if !provider.Valid(event, []string{"pullrequest:created", "pullrequest:updated", "pullrequest:comment_created"}) {
+		if !provider.Valid(event, []string{
+			"pullrequest:created", "pullrequest:updated", "pullrequest:comment_created",
+		}) {
 			return nil, fmt.Errorf("event %s is not supported", event)
 		}
 		localEvent = "pull_request"
@@ -163,24 +165,28 @@ func (v *Provider) ParsePayload(ctx context.Context, run *params.Run, request *h
 	return processedEvent, nil
 }
 
-func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool, *zap.SugaredLogger, error) {
+func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool,
+	*zap.SugaredLogger, string, error,
+) {
 	isBitCloud := false
 	event := reqHeader.Get("X-Event-Key")
 	if event == "" {
-		return false, false, logger, nil
+		return false, false, logger, "", nil
 	}
 
 	eventInt, err := parsePayloadType(event, payload)
 	if err != nil || eventInt == nil {
-		return false, false, logger, err
+		return false, false, logger, "", err
 	}
 
 	// it is a Bitbucket cloud event
 	isBitCloud = true
 
-	setLoggerAndProceed := func(processEvent bool, err error) (bool, bool, *zap.SugaredLogger, error) {
+	setLoggerAndProceed := func(processEvent bool, reason string, err error) (bool, bool, *zap.SugaredLogger,
+		string, error,
+	) {
 		logger = logger.With("provider", "bitbucket-cloud", "event", reqHeader.Get("X-Request-Id"))
-		return isBitCloud, processEvent, logger, err
+		return isBitCloud, processEvent, logger, reason, err
 	}
 
 	_ = json.Unmarshal([]byte(payload), &eventInt)
@@ -188,27 +194,27 @@ func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.Su
 	switch e := eventInt.(type) {
 	case *types.PullRequestEvent:
 		if provider.Valid(event, []string{"pullrequest:created", "pullrequest:updated"}) {
-			return setLoggerAndProceed(true, nil)
+			return setLoggerAndProceed(true, "", nil)
 		}
 		if provider.Valid(event, []string{"pullrequest:comment_created"}) {
 			if provider.IsRetestComment(e.Comment.Content.Raw) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 			if provider.IsOkToTestComment(e.Comment.Content.Raw) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, fmt.Sprintf("not a valid gitops comment: \"%s\"", event), nil)
 
 	case *types.PushRequestEvent:
 		if provider.Valid(event, []string{"repo:push"}) {
 			if e.Push.Changes != nil {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, fmt.Sprintf("invalid push event: \"%s\"", event), nil)
 
 	default:
-		return setLoggerAndProceed(false, fmt.Errorf("bitbucket-cloud: event %s is not recognized", event))
+		return setLoggerAndProceed(false, "", fmt.Errorf("bitbucket-cloud: event \"%s\" is not supported", event))
 	}
 }
diff --git a/pkg/provider/bitbucketserver/events.go b/pkg/provider/bitbucketserver/events.go
index 874d0a5d..7a215147 100644
--- a/pkg/provider/bitbucketserver/events.go
+++ b/pkg/provider/bitbucketserver/events.go
@@ -29,7 +29,9 @@ func sanitizeOwner(owner string) string {
 }
 
 // ParsePayload parses the payload from the event
-func (v *Provider) ParsePayload(ctx context.Context, run *params.Run, request *http.Request, payload string) (*info.Event, error) {
+func (v *Provider) ParsePayload(_ context.Context, _ *params.Run, request *http.Request,
+	payload string,
+) (*info.Event, error) {
 	processedEvent := info.NewEvent()
 
 	eventType := request.Header.Get("X-Event-Key")
@@ -102,12 +104,12 @@ func (v *Provider) ParsePayload(ctx context.Context, run *params.Run, request *h
 	// TODO: is this the right way? I guess i have no way to know what is the
 	// baseURL of a server unless there is something in the API?
 	// remove everything after /project in the URL to get the basePath
-	url, err := url.Parse(processedEvent.URL)
+	pURL, err := url.Parse(processedEvent.URL)
 	if err != nil {
 		return nil, err
 	}
 
-	v.baseURL = fmt.Sprintf("%s://%s", url.Scheme, url.Host)
+	v.baseURL = fmt.Sprintf("%s://%s", pURL.Scheme, pURL.Host)
 	return processedEvent, nil
 }
 
@@ -117,8 +119,10 @@ func parsePayloadType(event string) (interface{}, error) {
 	// and cloud, so we check the event name directly
 	var localEvent string
 	if strings.HasPrefix(event, "pr:") {
-		if !provider.Valid(event, []string{"pr:from_ref_updated", "pr:opened", "pr:comment:added", "pr:comment:edited"}) {
-			return nil, fmt.Errorf("event %s is not supported", event)
+		if !provider.Valid(event, []string{
+			"pr:from_ref_updated", "pr:opened", "pr:comment:added", "pr:comment:edited",
+		}) {
+			return nil, fmt.Errorf("event \"%s\" is not supported", event)
 		}
 		localEvent = "pull_request"
 	} else if event == "repo:refs_changed" {
@@ -139,24 +143,28 @@ func parsePayloadType(event string) (interface{}, error) {
 
 // Detect processes event and detect if it is a bitbucket server event, whether to process or reject it
 // returns (if is a bitbucket server event, whether to process or reject, error if any occurred)
-func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool, *zap.SugaredLogger, error) {
+func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool,
+	*zap.SugaredLogger, string, error,
+) {
 	isBitServer := false
 	event := reqHeader.Get("X-Event-Key")
 	if event == "" {
-		return false, false, logger, nil
+		return false, false, logger, "", nil
 	}
 
 	eventPayload, err := parsePayloadType(event)
 	if err != nil || eventPayload == nil {
-		return false, false, logger, err
+		return false, false, logger, "", err
 	}
 
 	// it is a Bitbucket server event
 	isBitServer = true
 
-	setLoggerAndProceed := func(processEvent bool, err error) (bool, bool, *zap.SugaredLogger, error) {
+	setLoggerAndProceed := func(processEvent bool, reason string, err error) (bool, bool, *zap.SugaredLogger, string,
+		error,
+	) {
 		logger = logger.With("provider", "bitbucket-server", "event", reqHeader.Get("X-Request-Id"))
-		return isBitServer, processEvent, logger, err
+		return isBitServer, processEvent, logger, reason, err
 	}
 
 	_ = json.Unmarshal([]byte(payload), &eventPayload)
@@ -164,27 +172,27 @@ func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.Su
 	switch e := eventPayload.(type) {
 	case *types.PullRequestEvent:
 		if provider.Valid(event, []string{"pr:from_ref_updated", "pr:opened"}) {
-			return setLoggerAndProceed(true, nil)
+			return setLoggerAndProceed(true, "", nil)
 		}
 		if provider.Valid(event, []string{"pr:comment:added"}) {
 			if provider.IsRetestComment(e.Comment.Text) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 			if provider.IsOkToTestComment(e.Comment.Text) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, fmt.Sprintf("not a recognized bitbucket event: \"%s\"", event), nil)
 
 	case *types.PushRequestEvent:
 		if provider.Valid(event, []string{"repo:refs_changed"}) {
 			if e.Changes != nil {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, fmt.Sprintf("not an event we support: \"%s\"", event), nil)
 
 	default:
-		return setLoggerAndProceed(false, fmt.Errorf("bitbucket-server: event %s is not supported", event))
+		return setLoggerAndProceed(false, "", fmt.Errorf("bitbucket-server: event \"%s\" is not supported", event))
 	}
 }
diff --git a/pkg/provider/github/github.go b/pkg/provider/github/github.go
index f9f44c77..6cdceb5f 100644
--- a/pkg/provider/github/github.go
+++ b/pkg/provider/github/github.go
@@ -215,24 +215,28 @@ func (v *Provider) getObject(ctx context.Context, sha string, runevent *info.Eve
 
 // Detect processes event and detect if it is a github event, whether to process or reject it
 // returns (if is a GH event, whether to process or reject, error if any occurred)
-func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool, *zap.SugaredLogger, error) {
+func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool,
+	*zap.SugaredLogger, string, error,
+) {
 	isGH := false
 	event := reqHeader.Get("X-Github-Event")
 	if event == "" {
-		return false, false, logger, nil
+		return false, false, logger, "", nil
 	}
 
 	// it is a Github event
 	isGH = true
 
-	setLoggerAndProceed := func(processEvent bool, err error) (bool, bool, *zap.SugaredLogger, error) {
+	setLoggerAndProceed := func(processEvent bool, reason string, err error) (bool, bool, *zap.SugaredLogger,
+		string, error,
+	) {
 		logger = logger.With("provider", "github", "event", reqHeader.Get("X-GitHub-Delivery"))
-		return isGH, processEvent, logger, err
+		return isGH, processEvent, logger, reason, err
 	}
 
 	eventInt, err := github.ParseWebHook(event, []byte(payload))
 	if err != nil {
-		return setLoggerAndProceed(false, err)
+		return setLoggerAndProceed(false, "", err)
 	}
 
 	_ = json.Unmarshal([]byte(payload), &eventInt)
@@ -240,36 +244,36 @@ func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.Su
 	switch gitEvent := eventInt.(type) {
 	case *github.CheckRunEvent:
 		if gitEvent.GetAction() == "rerequested" && gitEvent.GetCheckRun() != nil {
-			return setLoggerAndProceed(true, nil)
+			return setLoggerAndProceed(true, "", nil)
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, fmt.Sprintf("unsupported action \"%s\"", gitEvent.GetAction()), nil)
 
 	case *github.IssueCommentEvent:
 		if gitEvent.GetAction() == "created" &&
 			gitEvent.GetIssue().IsPullRequest() &&
 			gitEvent.GetIssue().GetState() == "open" {
 			if provider.IsRetestComment(gitEvent.GetComment().GetBody()) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 			if provider.IsOkToTestComment(gitEvent.GetComment().GetBody()) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
-			return setLoggerAndProceed(false, nil)
+			return setLoggerAndProceed(false, "", nil)
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, "not a gitops pull request comment", nil)
 	case *github.PushEvent:
 		if gitEvent.GetPusher() != nil {
-			return setLoggerAndProceed(true, nil)
+			return setLoggerAndProceed(true, "", nil)
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, "no push in event", nil)
 
 	case *github.PullRequestEvent:
 		if provider.Valid(gitEvent.GetAction(), []string{"opened", "synchronize", "reopened"}) {
-			return setLoggerAndProceed(true, nil)
+			return setLoggerAndProceed(true, "", nil)
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, fmt.Sprintf("unsupported action \"%s\"", gitEvent.GetAction()), nil)
 
 	default:
-		return setLoggerAndProceed(false, fmt.Errorf("github: event %v is not supported", event))
+		return setLoggerAndProceed(false, fmt.Sprintf("github: event \"%v\" is not supported", event), nil)
 	}
 }
diff --git a/pkg/provider/gitlab/gitlab.go b/pkg/provider/gitlab/gitlab.go
index 068bb581..a4487c79 100644
--- a/pkg/provider/gitlab/gitlab.go
+++ b/pkg/provider/gitlab/gitlab.go
@@ -48,7 +48,7 @@ func (v *Provider) SetLogger(logger *zap.SugaredLogger) {
 	v.Logger = logger
 }
 
-func (v *Provider) Validate(ctx context.Context, params *params.Run, event *info.Event) error {
+func (v *Provider) Validate(_ context.Context, _ *params.Run, event *info.Event) error {
 	token := event.Request.Header.Get("X-Gitlab-Token")
 	if event.Provider.WebhookSecret == "" && token != "" {
 		return fmt.Errorf("gitlab failed validaton: failed to find webhook secret")
@@ -61,47 +61,52 @@ func (v *Provider) Validate(ctx context.Context, params *params.Run, event *info
 
 // Detect processes event and detect if it is a gitlab event, whether to process or reject it
 // returns (if is a GL event, whether to process or reject, logger with event metadata,, error if any occurred)
-func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool, *zap.SugaredLogger, error) {
+func (v *Provider) Detect(reqHeader *http.Header, payload string, logger *zap.SugaredLogger) (bool, bool,
+	*zap.SugaredLogger, string, error,
+) {
 	isGL := false
 	event := reqHeader.Get("X-Gitlab-Event")
 	if event == "" {
-		return false, false, logger, nil
+		return false, false, logger, "no gitlab event", nil
 	}
 
 	// it is a Gitlab event
 	isGL = true
 
-	setLoggerAndProceed := func(processEvent bool, err error) (bool, bool, *zap.SugaredLogger, error) {
+	setLoggerAndProceed := func(processEvent bool, reason string, err error) (bool, bool, *zap.SugaredLogger,
+		string, error,
+	) {
 		logger = logger.With("provider", "gitlab", "event", reqHeader.Get("X-Request-Id"))
-		return isGL, processEvent, logger, err
+		return isGL, processEvent, logger, reason, err
 	}
 
 	eventInt, err := gitlab.ParseWebhook(gitlab.EventType(event), []byte(payload))
 	if err != nil {
-		return setLoggerAndProceed(false, err)
+		return setLoggerAndProceed(false, "", err)
 	}
 	_ = json.Unmarshal([]byte(payload), &eventInt)
 
 	switch gitEvent := eventInt.(type) {
 	case *gitlab.MergeEvent:
 		if provider.Valid(gitEvent.ObjectAttributes.Action, []string{"open", "update", "reopen"}) {
-			return setLoggerAndProceed(true, nil)
+			return setLoggerAndProceed(true, "", nil)
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, fmt.Sprintf("not a merge event we care about: \"%s\"",
+			gitEvent.ObjectAttributes.Action), nil)
 	case *gitlab.PushEvent:
-		return setLoggerAndProceed(true, nil)
+		return setLoggerAndProceed(true, "", nil)
 	case *gitlab.MergeCommentEvent:
 		if gitEvent.MergeRequest.State == "opened" {
 			if provider.IsRetestComment(gitEvent.ObjectAttributes.Note) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 			if provider.IsOkToTestComment(gitEvent.ObjectAttributes.Note) {
-				return setLoggerAndProceed(true, nil)
+				return setLoggerAndProceed(true, "", nil)
 			}
 		}
-		return setLoggerAndProceed(false, nil)
+		return setLoggerAndProceed(false, "not a gitops style merge comment event", nil)
 	default:
-		return setLoggerAndProceed(false, fmt.Errorf("gitlab: event %s is not supported", event))
+		return setLoggerAndProceed(false, "", fmt.Errorf("gitlab: event \"%s\" is not supported", event))
 	}
 }
 
@@ -119,7 +124,9 @@ func getOrgRepo(pathWithNamespace string) (string, string) {
 	return org, filepath.Base(pathWithNamespace)
 }
 
-func (v *Provider) ParsePayload(ctx context.Context, run *params.Run, request *http.Request, payload string) (*info.Event, error) {
+func (v *Provider) ParsePayload(_ context.Context, _ *params.Run, request *http.Request,
+	payload string,
+) (*info.Event, error) {
 	// TODO: parse request to figure out which event
 	var processedEvent *info.Event
 
@@ -217,13 +224,13 @@ func (v *Provider) GetConfig() *info.ProviderConfig {
 	}
 }
 
-func (v *Provider) SetClient(ctx context.Context, event *info.Event) error {
+func (v *Provider) SetClient(_ context.Context, event *info.Event) error {
 	var err error
 	if event.Provider.Token == "" {
 		return fmt.Errorf("no git_provider.secret has been set in the repo crd")
 	}
 
-	// Try to detect automatically theapi url if url is not coming from public
+	// Try to detect automatically the API url if url is not coming from public
 	// gitlab. Unless user has set a spec.provider.url in its repo crd
 	apiURL := apiPublicURL
 	if event.Provider.URL != "" {
@@ -240,7 +247,9 @@ func (v *Provider) SetClient(ctx context.Context, event *info.Event) error {
 	return nil
 }
 
-func (v *Provider) CreateStatus(ctx context.Context, event *info.Event, pacOpts *info.PacOpts, statusOpts provider.StatusOpts) error {
+func (v *Provider) CreateStatus(_ context.Context, event *info.Event, pacOpts *info.PacOpts,
+	statusOpts provider.StatusOpts,
+) error {
 	var detailsURL string
 	if v.Client == nil {
 		return fmt.Errorf("no gitlab client has been initiliazed, " +
@@ -298,7 +307,7 @@ func (v *Provider) CreateStatus(ctx context.Context, event *info.Event, pacOpts
 	return nil
 }
 
-func (v *Provider) GetTektonDir(ctx context.Context, event *info.Event, path string) (string, error) {
+func (v *Provider) GetTektonDir(_ context.Context, event *info.Event, path string) (string, error) {
 	if v.Client == nil {
 		return "", fmt.Errorf("no gitlab client has been initiliazed, " +
 			"exiting... (hint: did you forget setting a secret on your repo?)")
@@ -355,7 +364,7 @@ func (v *Provider) getObject(fname, branch string, pid int) ([]byte, error) {
 	return file, nil
 }
 
-func (v *Provider) GetFileInsideRepo(ctx context.Context, runevent *info.Event, path, _ string) (string, error) {
+func (v *Provider) GetFileInsideRepo(_ context.Context, runevent *info.Event, path, _ string) (string, error) {
 	getobj, err := v.getObject(path, runevent.HeadBranch, v.sourceProjectID)
 	if err != nil {
 		return "", err
@@ -363,7 +372,7 @@ func (v *Provider) GetFileInsideRepo(ctx context.Context, runevent *info.Event,
 	return string(getobj), nil
 }
 
-func (v *Provider) GetCommitInfo(ctx context.Context, event *info.Event) error {
+func (v *Provider) GetCommitInfo(_ context.Context, _ *info.Event) error {
 	if v.Client == nil {
 		return fmt.Errorf("no gitlab client has been initiliazed, " +
 			"exiting... (hint: did you forget setting a secret on your repo?)")
diff --git a/pkg/provider/interface.go b/pkg/provider/interface.go
index c2109e34..186af0b5 100644
--- a/pkg/provider/interface.go
+++ b/pkg/provider/interface.go
@@ -23,7 +23,7 @@ type StatusOpts struct {
 type Interface interface {
 	SetLogger(*zap.SugaredLogger)
 	Validate(ctx context.Context, params *params.Run, event *info.Event) error
-	Detect(*http.Header, string, *zap.SugaredLogger) (bool, bool, *zap.SugaredLogger, error)
+	Detect(*http.Header, string, *zap.SugaredLogger) (bool, bool, *zap.SugaredLogger, string, error)
 	ParsePayload(context.Context, *params.Run, *http.Request, string) (*info.Event, error)
 	IsAllowed(context.Context, *info.Event) (bool, error)
 	CreateStatus(context.Context, *info.Event, *info.PacOpts, StatusOpts) error


Test patch:
diff --git a/pkg/adapter/adapter_test.go b/pkg/adapter/adapter_test.go
index fa79d3bf..2d31b01c 100644
--- a/pkg/adapter/adapter_test.go
+++ b/pkg/adapter/adapter_test.go
@@ -138,7 +138,7 @@ func TestWhichProvider(t *testing.T) {
 				"foo": {"bar"},
 			},
 			event:         "interface",
-			wantErrString: "no supported Git Provider is detected",
+			wantErrString: "no supported Git provider has been detected",
 		},
 	}
 
diff --git a/pkg/provider/bitbucketcloud/bitbucket_test.go b/pkg/provider/bitbucketcloud/bitbucket_test.go
index 0546ef22..266b2590 100644
--- a/pkg/provider/bitbucketcloud/bitbucket_test.go
+++ b/pkg/provider/bitbucketcloud/bitbucket_test.go
@@ -268,6 +268,7 @@ func TestProvider_Detect(t *testing.T) {
 		processReq    bool
 		event         interface{}
 		eventType     string
+		wantReason    string
 	}{
 		{
 			name:       "not a bitbucket cloud Event",
@@ -365,11 +366,15 @@ func TestProvider_Detect(t *testing.T) {
 			header := &http.Header{}
 			header.Set("X-Event-Key", tt.eventType)
 
-			isBS, processReq, _, err := bprovider.Detect(header, string(jeez), logger)
+			isBS, processReq, _, reason, err := bprovider.Detect(header, string(jeez), logger)
 			if tt.wantErrString != "" {
 				assert.ErrorContains(t, err, tt.wantErrString)
 				return
 			}
+			if tt.wantReason != "" {
+				assert.Assert(t, strings.Contains(reason, tt.wantReason))
+				return
+			}
 			assert.NilError(t, err)
 			assert.Equal(t, tt.isBC, isBS)
 			assert.Equal(t, tt.processReq, processReq)
diff --git a/pkg/provider/bitbucketserver/bitbucketserver_test.go b/pkg/provider/bitbucketserver/bitbucketserver_test.go
index 95597e62..9fb779e0 100644
--- a/pkg/provider/bitbucketserver/bitbucketserver_test.go
+++ b/pkg/provider/bitbucketserver/bitbucketserver_test.go
@@ -4,7 +4,7 @@ import (
 	"context"
 	"crypto/hmac"
 
-	//nolint
+	// nolint
 	"crypto/sha1"
 	"crypto/sha256"
 	"encoding/hex"
@@ -345,6 +345,7 @@ func TestProvider_Detect(t *testing.T) {
 		processReq    bool
 		event         interface{}
 		eventType     string
+		wantReason    string
 	}{
 		{
 			name:       "not a bitbucket server Event",
@@ -432,11 +433,15 @@ func TestProvider_Detect(t *testing.T) {
 			header := &http.Header{}
 			header.Set("X-Event-Key", tt.eventType)
 
-			isBS, processReq, _, err := bprovider.Detect(header, string(jeez), logger)
+			isBS, processReq, _, reason, err := bprovider.Detect(header, string(jeez), logger)
 			if tt.wantErrString != "" {
 				assert.ErrorContains(t, err, tt.wantErrString)
 				return
 			}
+			if tt.wantReason != "" {
+				assert.Assert(t, strings.Contains(reason, tt.wantReason))
+				return
+			}
 			assert.NilError(t, err)
 			assert.Equal(t, tt.isBS, isBS)
 			assert.Equal(t, tt.processReq, processReq)
diff --git a/pkg/provider/bitbucketserver/events_test.go b/pkg/provider/bitbucketserver/events_test.go
index 2d4f6be0..de6212fd 100644
--- a/pkg/provider/bitbucketserver/events_test.go
+++ b/pkg/provider/bitbucketserver/events_test.go
@@ -37,7 +37,7 @@ func TestParsePayload(t *testing.T) {
 			name:          "bad/invalid event type",
 			eventType:     "pr:nono",
 			payloadEvent:  bbv1.PullRequest{},
-			wantErrSubstr: "event pr:nono is not supported",
+			wantErrSubstr: "event \"pr:nono\" is not supported",
 		},
 		{
 			name:          "bad/bad json",
diff --git a/pkg/provider/github/github_test.go b/pkg/provider/github/github_test.go
index b7192083..597cf5df 100644
--- a/pkg/provider/github/github_test.go
+++ b/pkg/provider/github/github_test.go
@@ -380,6 +380,7 @@ func TestProvider_Detect(t *testing.T) {
 		processReq    bool
 		event         interface{}
 		eventType     string
+		wantReason    string
 	}{
 		{
 			name:       "not a github Event",
@@ -411,10 +412,10 @@ func TestProvider_Detect(t *testing.T) {
 			event: github.CommitCommentEvent{
 				Action: github.String("something"),
 			},
-			eventType:     "commit_comment",
-			wantErrString: "github: event commit_comment is not supported",
-			isGH:          true,
-			processReq:    false,
+			eventType:  "commit_comment",
+			wantReason: "event \"commit_comment\" is not supported",
+			isGH:       true,
+			processReq: false,
 		},
 		{
 			name: "invalid check run Event",
@@ -571,11 +572,15 @@ func TestProvider_Detect(t *testing.T) {
 			header := &http.Header{}
 			header.Set("X-GitHub-Event", tt.eventType)
 
-			isGh, processReq, _, err := gprovider.Detect(header, string(jeez), logger)
+			isGh, processReq, _, reason, err := gprovider.Detect(header, string(jeez), logger)
 			if tt.wantErrString != "" {
 				assert.ErrorContains(t, err, tt.wantErrString)
 				return
 			}
+			if tt.wantReason != "" {
+				assert.Assert(t, strings.Contains(reason, tt.wantReason), reason, tt.wantReason)
+				return
+			}
 			assert.NilError(t, err)
 			assert.Equal(t, tt.isGH, isGh)
 			assert.Equal(t, tt.processReq, processReq)
diff --git a/pkg/provider/gitlab/gitlab_test.go b/pkg/provider/gitlab/gitlab_test.go
index f4240b34..b4772bfb 100644
--- a/pkg/provider/gitlab/gitlab_test.go
+++ b/pkg/provider/gitlab/gitlab_test.go
@@ -488,6 +488,7 @@ func TestProvider_Detect(t *testing.T) {
 		processReq    bool
 		event         string
 		eventType     gitlab.EventType
+		wantReason    string
 	}{
 		{
 			name:       "not a gitlab Event",
@@ -554,12 +555,16 @@ func TestProvider_Detect(t *testing.T) {
 			header := &http.Header{}
 			header.Set("X-Gitlab-Event", string(tt.eventType))
 
-			isGL, processReq, _, err := gprovider.Detect(header, tt.event, logger)
+			isGL, processReq, _, reason, err := gprovider.Detect(header, tt.event, logger)
 			if tt.wantErrString != "" {
 				assert.ErrorContains(t, err, tt.wantErrString)
 				return
 			}
 			assert.NilError(t, err)
+			if tt.wantReason != "" {
+				assert.Assert(t, strings.Contains(reason, tt.wantReason))
+				return
+			}
 			assert.Equal(t, tt.isGL, isGL)
 			assert.Equal(t, tt.processReq, processReq)
 		})
diff --git a/pkg/test/provider/testwebvcs.go b/pkg/test/provider/testwebvcs.go
index a3119f3d..8645ae8b 100644
--- a/pkg/test/provider/testwebvcs.go
+++ b/pkg/test/provider/testwebvcs.go
@@ -26,8 +26,10 @@ func (v *TestProviderImp) Validate(ctx context.Context, params *params.Run, even
 	return nil
 }
 
-func (v *TestProviderImp) Detect(request *http.Header, body string, logger *zap.SugaredLogger) (bool, bool, *zap.SugaredLogger, error) {
-	return true, true, nil, nil
+func (v *TestProviderImp) Detect(request *http.Header, body string, logger *zap.SugaredLogger) (bool, bool,
+	*zap.SugaredLogger, string, error,
+) {
+	return true, true, nil, "", nil
 }
 
 func (v *TestProviderImp) ParsePayload(ctx context.Context, run *params.Run, request *http.Request, payload string) (*info.Event, error) {