Skip to content

Commit

Permalink
handle conversion errors as 400
Browse files Browse the repository at this point in the history
Signed-off-by: Isabella do Amaral <idoamara@redhat.com>
  • Loading branch information
isinyaaa committed Apr 30, 2024
1 parent 30c2c9f commit ae57797
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 65 deletions.
22 changes: 11 additions & 11 deletions internal/server/openapi/api_model_registry_service_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *ModelRegistryServiceAPIService) CreateEnvironmentInferenceService(ctx c
func (s *ModelRegistryServiceAPIService) CreateInferenceService(ctx context.Context, inferenceServiceCreate model.InferenceServiceCreate) (ImplResponse, error) {
entity, err := s.converter.ConvertInferenceServiceCreate(&inferenceServiceCreate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}

result, err := s.coreApi.UpsertInferenceService(entity)
Expand All @@ -65,7 +65,7 @@ func (s *ModelRegistryServiceAPIService) CreateInferenceService(ctx context.Cont
func (s *ModelRegistryServiceAPIService) CreateInferenceServiceServe(ctx context.Context, inferenceserviceId string, serveModelCreate model.ServeModelCreate) (ImplResponse, error) {
entity, err := s.converter.ConvertServeModelCreate(&serveModelCreate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}

result, err := s.coreApi.UpsertServeModel(entity, &inferenceserviceId)
Expand All @@ -87,7 +87,7 @@ func (s *ModelRegistryServiceAPIService) CreateInferenceServiceServe(ctx context
func (s *ModelRegistryServiceAPIService) CreateModelArtifact(ctx context.Context, modelArtifactCreate model.ModelArtifactCreate) (ImplResponse, error) {
entity, err := s.converter.ConvertModelArtifactCreate(&modelArtifactCreate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}

result, err := s.coreApi.UpsertModelArtifact(entity, nil)
Expand All @@ -105,7 +105,7 @@ func (s *ModelRegistryServiceAPIService) CreateModelArtifact(ctx context.Context
func (s *ModelRegistryServiceAPIService) CreateModelVersion(ctx context.Context, modelVersionCreate model.ModelVersionCreate) (ImplResponse, error) {
modelVersion, err := s.converter.ConvertModelVersionCreate(&modelVersionCreate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}

result, err := s.coreApi.UpsertModelVersion(modelVersion, &modelVersionCreate.RegisteredModelId)
Expand Down Expand Up @@ -138,7 +138,7 @@ func (s *ModelRegistryServiceAPIService) CreateModelVersionArtifact(ctx context.
func (s *ModelRegistryServiceAPIService) CreateRegisteredModel(ctx context.Context, registeredModelCreate model.RegisteredModelCreate) (ImplResponse, error) {
registeredModel, err := s.converter.ConvertRegisteredModelCreate(&registeredModelCreate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}

result, err := s.coreApi.UpsertRegisteredModel(registeredModel)
Expand Down Expand Up @@ -172,7 +172,7 @@ func (s *ModelRegistryServiceAPIService) CreateRegisteredModelVersion(ctx contex
func (s *ModelRegistryServiceAPIService) CreateServingEnvironment(ctx context.Context, servingEnvironmentCreate model.ServingEnvironmentCreate) (ImplResponse, error) {
entity, err := s.converter.ConvertServingEnvironmentCreate(&servingEnvironmentCreate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}

result, err := s.coreApi.UpsertServingEnvironment(entity)
Expand Down Expand Up @@ -521,7 +521,7 @@ func (s *ModelRegistryServiceAPIService) GetServingEnvironments(ctx context.Cont
func (s *ModelRegistryServiceAPIService) UpdateInferenceService(ctx context.Context, inferenceserviceId string, inferenceServiceUpdate model.InferenceServiceUpdate) (ImplResponse, error) {
entity, err := s.converter.ConvertInferenceServiceUpdate(&inferenceServiceUpdate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}
entity.Id = &inferenceserviceId
result, err := s.coreApi.UpsertInferenceService(entity)
Expand All @@ -542,7 +542,7 @@ func (s *ModelRegistryServiceAPIService) UpdateInferenceService(ctx context.Cont
func (s *ModelRegistryServiceAPIService) UpdateModelArtifact(ctx context.Context, modelartifactId string, modelArtifactUpdate model.ModelArtifactUpdate) (ImplResponse, error) {
modelArtifact, err := s.converter.ConvertModelArtifactUpdate(&modelArtifactUpdate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}
modelArtifact.Id = &modelartifactId
result, err := s.coreApi.UpsertModelArtifact(modelArtifact, nil)
Expand All @@ -563,7 +563,7 @@ func (s *ModelRegistryServiceAPIService) UpdateModelArtifact(ctx context.Context
func (s *ModelRegistryServiceAPIService) UpdateModelVersion(ctx context.Context, modelversionId string, modelVersionUpdate model.ModelVersionUpdate) (ImplResponse, error) {
modelVersion, err := s.converter.ConvertModelVersionUpdate(&modelVersionUpdate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}
modelVersion.Id = &modelversionId
result, err := s.coreApi.UpsertModelVersion(modelVersion, nil)
Expand All @@ -584,7 +584,7 @@ func (s *ModelRegistryServiceAPIService) UpdateModelVersion(ctx context.Context,
func (s *ModelRegistryServiceAPIService) UpdateRegisteredModel(ctx context.Context, registeredmodelId string, registeredModelUpdate model.RegisteredModelUpdate) (ImplResponse, error) {
registeredModel, err := s.converter.ConvertRegisteredModelUpdate(&registeredModelUpdate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}
registeredModel.Id = &registeredmodelId
result, err := s.coreApi.UpsertRegisteredModel(registeredModel)
Expand All @@ -605,7 +605,7 @@ func (s *ModelRegistryServiceAPIService) UpdateRegisteredModel(ctx context.Conte
func (s *ModelRegistryServiceAPIService) UpdateServingEnvironment(ctx context.Context, servingenvironmentId string, servingEnvironmentUpdate model.ServingEnvironmentUpdate) (ImplResponse, error) {
entity, err := s.converter.ConvertServingEnvironmentUpdate(&servingEnvironmentUpdate)
if err != nil {
return Response(500, model.Error{Message: err.Error()}), nil
return Response(400, model.Error{Message: err.Error()}), nil
}
entity.Id = &servingenvironmentId
result, err := s.coreApi.UpsertServingEnvironment(entity)
Expand Down
Loading

0 comments on commit ae57797

Please sign in to comment.