Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httptransport: GET vuln report returns 404 when indexing in-progress #1963

Merged
merged 1 commit into from
Mar 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions httptransport/matcher_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/google/uuid"
"github.com/quay/claircore"
indexerController "github.com/quay/claircore/indexer/controller"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't bother with the alias here.

"github.com/quay/claircore/libvuln/driver"
"github.com/quay/zlog"
oteltrace "go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace"
Expand Down Expand Up @@ -125,9 +126,10 @@ func (h *MatcherV1) vulnerabilityReport(w http.ResponseWriter, r *http.Request)
if err != nil {
apiError(ctx, w, http.StatusInternalServerError, "experienced a server side error: %v", err)
}
// now check bool only after confirming no err
if !ok {
// now check present and finished only after confirming no err
if !ok || indexReport.State != indexerController.IndexFinished.String() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit but it might be nicer to compare the state types as opposed to the strings:

var state controller.State
state.FromString(indexReport.State)
if !ok || state != controller.IndexFinished {
...

apiError(ctx, w, http.StatusNotFound, "index report for manifest %q not found", manifest.String())
return
}

vulnReport, err := h.srv.Scan(ctx, indexReport)
Expand Down
Loading