Skip to content

Commit

Permalink
fix: fix problemDetails nil issue and nil pointer dereferences
Browse files Browse the repository at this point in the history
  • Loading branch information
TYuan0816 committed Sep 10, 2024
1 parent 515e580 commit c20a740
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions internal/sbi/consumer/nrf_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ func (s *nnrfService) SendSearchNFInstances(
}

res, err := client.NFInstancesStoreApi.SearchNFInstances(ctx, &param)
result := res.SearchResult

if err != nil {
if err != nil || res == nil {
logger.ConsumerLog.Errorf("SearchNFInstances failed: %+v", err)
return nil, err
}

result := res.SearchResult
return &result, err
}

Expand All @@ -116,7 +116,15 @@ func (s *nnrfService) SendDeregisterNFInstance() (problemDetails *models.Problem
}

_, err = client.NFInstanceIDDocumentApi.DeregisterNFInstance(ctx, request)
return problemDetails, err

switch e := err.(type) {
case openapi.GenericOpenAPIError:
return e.Model().(*models.ProblemDetails), nil
case nil:
return nil, nil
default:
return nil, err
}
}

func (s *nnrfService) RegisterNFInstance(ctx context.Context) (
Expand Down

0 comments on commit c20a740

Please sign in to comment.