diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-04-29 08:23:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-29 00:23:35 +0000 |
commit | d07019f539c475466748fbf730d7f270a92fdb8b (patch) | |
tree | 9e35d86e3eba37f924cad08dabdd14554f88b579 | |
parent | bb7d36d7518b7e69c1aec3cb47584b85d3a43959 (diff) | |
download | gitea-d07019f539c475466748fbf730d7f270a92fdb8b.tar.gz gitea-d07019f539c475466748fbf730d7f270a92fdb8b.zip |
Fix nil dereference on error (#30740) (#30746)
Backport #30740 manually
Co-authored-by: Chongyi Zheng <git@zcy.dev>
-rw-r--r-- | routers/api/actions/artifacts.go | 7 | ||||
-rw-r--r-- | routers/web/repo/actions/view.go | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/routers/api/actions/artifacts.go b/routers/api/actions/artifacts.go index 3e717b8d8f..5bd004bd37 100644 --- a/routers/api/actions/artifacts.go +++ b/routers/api/actions/artifacts.go @@ -466,14 +466,15 @@ func (ar artifactRoutes) downloadArtifact(ctx *ArtifactContext) { log.Error("Error getting artifact: %v", err) ctx.Error(http.StatusInternalServerError, err.Error()) return - } else if !exist { + } + if !exist { log.Error("artifact with ID %d does not exist", artifactID) ctx.Error(http.StatusNotFound, fmt.Sprintf("artifact with ID %d does not exist", artifactID)) return } if artifact.RunID != runID { - log.Error("Error dismatch runID and artifactID, task: %v, artifact: %v", runID, artifactID) - ctx.Error(http.StatusBadRequest, err.Error()) + log.Error("Error mismatch runID and artifactID, task: %v, artifact: %v", runID, artifactID) + ctx.Error(http.StatusBadRequest) return } diff --git a/routers/web/repo/actions/view.go b/routers/web/repo/actions/view.go index 3909a64be6..12909bddd5 100644 --- a/routers/web/repo/actions/view.go +++ b/routers/web/repo/actions/view.go @@ -504,7 +504,7 @@ func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions return nil, nil } if len(jobs) == 0 { - ctx.Error(http.StatusNotFound, err.Error()) + ctx.Error(http.StatusNotFound) return nil, nil } |