@@ -19,6 +19,7 @@ import (
1919 "bytes"
2020 "context"
2121 "encoding/hex"
22+ "errors"
2223 "fmt"
2324 "net/http"
2425 "net/url"
@@ -30,7 +31,6 @@ import (
3031 "github.com/go-openapi/swag"
3132 "github.com/google/trillian"
3233 ttypes "github.com/google/trillian/types"
33- "github.com/pkg/errors"
3434 "github.com/spf13/viper"
3535 "github.com/transparency-dev/merkle/rfc6962"
3636 "golang.org/x/sync/errgroup"
@@ -313,7 +313,10 @@ func getEntryURL(locationURL url.URL, uuid string) strfmt.URI {
313313func GetLogEntryByUUIDHandler (params entries.GetLogEntryByUUIDParams ) middleware.Responder {
314314 logEntry , err := retrieveLogEntry (params .HTTPRequest .Context (), params .EntryUUID )
315315 if err != nil {
316- return handleRekorAPIError (params , http .StatusNotFound , err , "ID %s not found in any known trees" , params .EntryUUID )
316+ if _ , ok := (err ).(types.ValidationError ); ok {
317+ return handleRekorAPIError (params , http .StatusBadRequest , err , "incorrectly formatted uuid %s" , params .EntryUUID )
318+ }
319+ return handleRekorAPIError (params , http .StatusInternalServerError , err , "ID %s not found in any known trees" , params .EntryUUID )
317320 }
318321 return entries .NewGetLogEntryByUUIDOK ().WithPayload (logEntry )
319322}
@@ -333,8 +336,7 @@ func SearchLogQueryHandler(params entries.SearchLogQueryParams) middleware.Respo
333336 if err != nil {
334337 return handleRekorAPIError (params , http .StatusBadRequest , err , fmt .Sprintf ("could not get UUID from ID string %v" , entryID ))
335338 }
336- logEntry , err := retrieveLogEntry (httpReqCtx , entryID )
337- if err == nil {
339+ if logEntry , err := retrieveLogEntry (httpReqCtx , entryID ); err == nil {
338340 resultPayload = append (resultPayload , logEntry )
339341 continue
340342 }
@@ -455,7 +457,7 @@ var ErrNotFound = errors.New("grpc returned 0 leaves with success code")
455457func retrieveLogEntry (ctx context.Context , entryUUID string ) (models.LogEntry , error ) {
456458 uuid , err := sharding .GetUUIDFromIDString (entryUUID )
457459 if err != nil {
458- return models.LogEntry {}, errors . Wrap ( err , "getting uuid from id string" )
460+ return models.LogEntry {}, sharding . ErrPlainUUID
459461 }
460462
461463 // Get the tree ID and check that shard for the entry
@@ -484,7 +486,7 @@ func retrieveLogEntry(ctx context.Context, entryUUID string) (models.LogEntry, e
484486func retrieveUUIDFromTree (ctx context.Context , uuid string , tid int64 ) (models.LogEntry , error ) {
485487 hashValue , err := hex .DecodeString (uuid )
486488 if err != nil {
487- return models.LogEntry {}, err
489+ return models.LogEntry {}, types . ValidationError ( err )
488490 }
489491
490492 tc := NewTrillianClientFromTreeID (ctx , tid )
0 commit comments