Return 204 not 500 on filtered pipeline (#2230)

the error check always failed, as the custom errors did not have the
`Is(error) bool` interface implemented

backport bugfix part of  #2216
This commit is contained in:
6543
2023-08-17 14:46:22 +02:00
committed by GitHub
parent 2d0a6e7702
commit a31752eb55
2 changed files with 25 additions and 1 deletions

View File

@@ -66,7 +66,7 @@ func Create(ctx context.Context, _store store.Store, repo *model.Repo, pipeline
filtered, parseErr = checkIfFiltered(repo, pipeline, forgeYamlConfigs)
if parseErr == nil {
if filtered {
err := ErrFiltered{Msg: "branch does not match restrictions defined in yaml"}
err := ErrFiltered{Msg: "global when filter of all workflows do skip this pipeline"}
log.Debug().Str("repo", repo.FullName).Msgf("%v", err)
return nil, err
}

View File

@@ -22,6 +22,14 @@ func (e ErrNotFound) Error() string {
return e.Msg
}
func (e ErrNotFound) Is(target error) bool {
_, ok := target.(ErrNotFound) //nolint:errorlint
if !ok {
_, ok = target.(*ErrNotFound) //nolint:errorlint
}
return ok
}
type ErrBadRequest struct {
Msg string
}
@@ -30,6 +38,14 @@ func (e ErrBadRequest) Error() string {
return e.Msg
}
func (e ErrBadRequest) Is(target error) bool {
_, ok := target.(ErrBadRequest) //nolint:errorlint
if !ok {
_, ok = target.(*ErrBadRequest) //nolint:errorlint
}
return ok
}
type ErrFiltered struct {
Msg string
}
@@ -37,3 +53,11 @@ type ErrFiltered struct {
func (e ErrFiltered) Error() string {
return "ignoring hook: " + e.Msg
}
func (e *ErrFiltered) Is(target error) bool {
_, ok := target.(ErrFiltered) //nolint:errorlint
if !ok {
_, ok = target.(*ErrFiltered) //nolint:errorlint
}
return ok
}