Skip to content

Commit

Permalink
DEVPROD-11922: Prevent task page from erroring due to missing distro (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
minnakt authored Nov 25, 2024
1 parent 58fc889 commit d0a7b12
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
5 changes: 5 additions & 0 deletions graphql/tests/task/imageId/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
"_id": "container-task",
"branch": "spruce",
"container": "ubuntu1604-container"
},
{
"_id": "nonexistent-distro-task",
"branch": "spruce",
"distro": "i-was-deleted"
}
],
"distro": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
task(taskId: "nonexistent-distro-task") {
imageId
}
}
10 changes: 10 additions & 0 deletions graphql/tests/task/imageId/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@
}
}
}
},
{
"query_file": "nonexistent_distro_task.graphql",
"result": {
"data": {
"task": {
"imageId": ""
}
}
}
}
]
}
3 changes: 2 additions & 1 deletion model/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,9 @@ func GetImageIDFromDistro(ctx context.Context, distro string) (string, error) {
if err != nil {
return "", errors.Wrapf(err, "finding distro '%s'", distro)
}
// Do not return an error, as the distro may have been deleted.
if d == nil {
return "", errors.Errorf("distro '%s' not found", distro)
return "", nil
}
return d.ImageID, nil
}

0 comments on commit d0a7b12

Please sign in to comment.