mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2026-04-15 01:41:56 +00:00
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:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user