Skip to content

Commit 970965f

Browse files
authored
Fix nil dereference on error (go-gitea#30740)
In both cases, the `err` is nil because of `if` checks before Reference: go-gitea#30729
1 parent 8b8b48e commit 970965f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

routers/api/actions/artifacts.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -466,14 +466,15 @@ func (ar artifactRoutes) downloadArtifact(ctx *ArtifactContext) {
466466
log.Error("Error getting artifact: %v", err)
467467
ctx.Error(http.StatusInternalServerError, err.Error())
468468
return
469-
} else if !exist {
469+
}
470+
if !exist {
470471
log.Error("artifact with ID %d does not exist", artifactID)
471472
ctx.Error(http.StatusNotFound, fmt.Sprintf("artifact with ID %d does not exist", artifactID))
472473
return
473474
}
474475
if artifact.RunID != runID {
475-
log.Error("Error dismatch runID and artifactID, task: %v, artifact: %v", runID, artifactID)
476-
ctx.Error(http.StatusBadRequest, err.Error())
476+
log.Error("Error mismatch runID and artifactID, task: %v, artifact: %v", runID, artifactID)
477+
ctx.Error(http.StatusBadRequest)
477478
return
478479
}
479480

routers/web/repo/actions/view.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ func getRunJobs(ctx *context_module.Context, runIndex, jobIndex int64) (*actions
504504
return nil, nil
505505
}
506506
if len(jobs) == 0 {
507-
ctx.Error(http.StatusNotFound, err.Error())
507+
ctx.Error(http.StatusNotFound)
508508
return nil, nil
509509
}
510510

0 commit comments

Comments
 (0)