]> source.dussan.org Git - gitea.git/commitdiff
Fix nil dereference on error (#30740) (#30746)
authorwxiaoguang <wxiaoguang@gmail.com>
Mon, 29 Apr 2024 00:23:35 +0000 (08:23 +0800)
committerGitHub <noreply@github.com>
Mon, 29 Apr 2024 00:23:35 +0000 (00:23 +0000)
Backport #30740 manually

Co-authored-by: Chongyi Zheng <git@zcy.dev>
routers/api/actions/artifacts.go
routers/web/repo/actions/view.go

index 3e717b8d8f9eba433fdca09eccca60a4e2faaa69..5bd004bd374a67307197faf0e369313a77ced1b2 100644 (file)
@@ -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
        }
 
index 3909a64be60692761e066e1d765161715bacc0bb..12909bddd55bf465353ac0239cd2f781d5c909f3 100644 (file)
@@ -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
        }