api/v1: check for nil data before reading
After parsing the osbuild output, immediately check if any data was set before dereferencing pointers.
This commit is contained in:
parent
8dbf3e48c0
commit
42d7979d65
1 changed files with 5 additions and 0 deletions
|
|
@ -522,6 +522,11 @@ func (h *apiHandlers) ComposeMetadata(ctx echo.Context, id string) error {
|
|||
return echo.NewHTTPError(http.StatusNotFound, "Job %s not found: %s", id, err)
|
||||
}
|
||||
|
||||
if result.OSBuildOutput == nil || result.OSBuildOutput.Stages == nil {
|
||||
// no data to work with; parse error
|
||||
return echo.NewHTTPError(http.StatusInternalServerError, "Failed to read metadata for job %s", id)
|
||||
}
|
||||
|
||||
var job worker.OSBuildJob
|
||||
if _, _, _, err = h.server.workers.Job(jobId, &job); err != nil {
|
||||
return echo.NewHTTPError(http.StatusNotFound, "Job %s not found: %s", id, err)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue