Skip to content

Commit

Permalink
Don't unnecessarily extract uuid
Browse files Browse the repository at this point in the history
Signed-off-by: Priya Wadhwa <priya@chainguard.dev>
  • Loading branch information
priyawadhwa committed Aug 30, 2022
1 parent 66eb52c commit aebe35f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/api/entries.go
Expand Up @@ -338,11 +338,11 @@ func SearchLogQueryHandler(params entries.SearchLogQueryParams) middleware.Respo
resultPayload = append(resultPayload, logEntry)
continue
}
uuid, err := sharding.GetUUIDFromIDString(entryID)
if err != nil {
return handleRekorAPIError(params, http.StatusBadRequest, err, fmt.Sprintf("could not get UUID from ID string %v", entryID))
// At this point, check if we got a uuid instead of an EntryID, so search for the hash later
uuid := entryID
if err := sharding.ValidateUUID(uuid); err != nil {
return handleRekorAPIError(params, http.StatusBadRequest, err, fmt.Sprintf("validating uuid %s", uuid))
}
// If we couldn't get the entry, search for the hash later
hash, err := hex.DecodeString(uuid)
if err != nil {
return handleRekorAPIError(params, http.StatusBadRequest, err, malformedUUID)
Expand Down

0 comments on commit aebe35f

Please sign in to comment.