Skip to content

Commit

Permalink
Handle case where there is no latest pipeline for GetBadge (#2042) (#…
Browse files Browse the repository at this point in the history
…2050)

Backport #2042

address  error 2 of #2036
  • Loading branch information
6543 authored Jul 28, 2023
1 parent 196af15 commit 9fdb5d9
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions server/api/badge.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ func GetBadge(c *gin.Context) {

pipeline, err := _store.GetPipelineLast(repo, branch)
if err != nil {
log.Warn().Err(err).Msg("")
if !errors.Is(err, types.RecordNotExist) {
log.Warn().Err(err).Msg("could not get last pipeline for badge")
}
pipeline = nil
}

Expand Down Expand Up @@ -110,7 +112,12 @@ func GetCC(c *gin.Context) {
}

pipelines, err := _store.GetPipelineList(repo, &model.ListOptions{Page: 1, PerPage: 1})
if err != nil || len(pipelines) == 0 {
if err != nil && !errors.Is(err, types.RecordNotExist) {
log.Warn().Err(err).Msg("could not get pipeline list")
c.AbortWithStatus(http.StatusInternalServerError)
return
}
if len(pipelines) == 0 {
c.AbortWithStatus(http.StatusNotFound)
return
}
Expand Down

0 comments on commit 9fdb5d9

Please sign in to comment.