From 766ec092cb4919bc9751c06a5a1a941162e2bcf5 Mon Sep 17 00:00:00 2001 From: Isabella Basso Date: Tue, 4 Jun 2024 13:00:02 -0300 Subject: [PATCH] Fix http error codes (#125) * core: rearrange fields to reduce struct size Signed-off-by: Isabella do Amaral * ignore debug files Signed-off-by: Isabella do Amaral * api: fix http status error conversion Signed-off-by: Isabella do Amaral --------- Signed-off-by: Isabella do Amaral --- .gitignore | 2 ++ pkg/api/error.go | 2 +- pkg/core/core.go | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 01ceb11b..c513fad9 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,8 @@ # Test binary, built with `go test -c` *.test +__debug* + # Output of the go coverage tool, specifically when used with LiteIDE *.out diff --git a/pkg/api/error.go b/pkg/api/error.go index b5e498e8..04d857d5 100644 --- a/pkg/api/error.go +++ b/pkg/api/error.go @@ -11,7 +11,7 @@ var ( ) func ErrToStatus(err error) int { - switch err { + switch errors.Unwrap(err) { case ErrBadRequest: return http.StatusBadRequest case ErrNotFound: diff --git a/pkg/core/core.go b/pkg/core/core.go index 7d41873b..fae55169 100644 --- a/pkg/core/core.go +++ b/pkg/core/core.go @@ -20,10 +20,10 @@ import ( // ModelRegistryService is the core library of the model registry type ModelRegistryService struct { mlmdClient proto.MetadataStoreServiceClient - nameConfig mlmdtypes.MLMDTypeNamesConfig typesMap map[string]int64 mapper *mapper.Mapper openapiConv *generated.OpenAPIConverterImpl + nameConfig mlmdtypes.MLMDTypeNamesConfig } // NewModelRegistryService creates a new instance of the ModelRegistryService, initializing it with the provided gRPC client connection.