99 "github.com/google/uuid"
1010 "github.com/kubeflow/model-registry/internal/defaults"
1111 "github.com/kubeflow/model-registry/internal/ml_metadata/proto"
12+ "github.com/kubeflow/model-registry/pkg/api"
1213 "github.com/kubeflow/model-registry/pkg/openapi"
1314 "google.golang.org/protobuf/types/known/structpb"
1415)
@@ -65,7 +66,7 @@ func MapOpenAPICustomProperties(source *map[string]openapi.MetadataValue) (map[s
6566 case v .MetadataIntValue != nil :
6667 intValue , err := StringToInt64 (& v .MetadataIntValue .IntValue )
6768 if err != nil {
68- return nil , fmt .Errorf ("unable to decode as int64 %w for key %s" , err , key )
69+ return nil , fmt .Errorf ("%w: unable to decode as int64 %w for key %s" , api . ErrBadRequest , err , key )
6970 }
7071 value .Value = & proto.Value_IntValue {IntValue : * intValue }
7172 // double value
@@ -78,22 +79,22 @@ func MapOpenAPICustomProperties(source *map[string]openapi.MetadataValue) (map[s
7879 case v .MetadataStructValue != nil :
7980 data , err := base64 .StdEncoding .DecodeString (v .MetadataStructValue .StructValue )
8081 if err != nil {
81- return nil , fmt .Errorf ("unable to decode %w for key %s" , err , key )
82+ return nil , fmt .Errorf ("%w: unable to decode %w for key %s" , api . ErrBadRequest , err , key )
8283 }
8384 var asMap map [string ]interface {}
8485 err = json .Unmarshal (data , & asMap )
8586 if err != nil {
86- return nil , fmt .Errorf ("unable to decode %w for key %s" , err , key )
87+ return nil , fmt .Errorf ("%w: unable to decode %w for key %s" , api . ErrBadRequest , err , key )
8788 }
8889 asStruct , err := structpb .NewStruct (asMap )
8990 if err != nil {
90- return nil , fmt .Errorf ("unable to decode %w for key %s" , err , key )
91+ return nil , fmt .Errorf ("%w: unable to decode %w for key %s" , api . ErrBadRequest , err , key )
9192 }
9293 value .Value = & proto.Value_StructValue {
9394 StructValue : asStruct ,
9495 }
9596 default :
96- return nil , fmt .Errorf ("type mapping not found for %s:%v" , key , v )
97+ return nil , fmt .Errorf ("%w: metadataType not found for %s: %v" , api . ErrBadRequest , key , v )
9798 }
9899
99100 props [key ] = & value
0 commit comments