diff --git a/internal/api/connectors/inventory/inventory.go b/internal/api/connectors/inventory/inventory.go index 3a186717..018acaad 100644 --- a/internal/api/connectors/inventory/inventory.go +++ b/internal/api/connectors/inventory/inventory.go @@ -142,6 +142,10 @@ func (this *inventoryConnectorImpl) getHostDetails( return nil, err } + if response.StatusCode() == http.StatusNotFound { + return []HostOut{}, nil + } + if response.JSON200 == nil { return nil, utils.UnexpectedResponse(response.HTTPResponse) } @@ -184,7 +188,7 @@ func (this *inventoryConnectorImpl) GetHostConnectionDetails(ctx context.Context } if len(hostResults) == 0 { - return nil, nil + return []HostDetails{}, nil } systemProfileResults, err := this.getSystemProfileDetails(ctx, IDs, order_by, order_how, limit, offset) diff --git a/internal/api/controllers/private/highlevelConnectionStatus.go b/internal/api/controllers/private/highlevelConnectionStatus.go index 7e95555a..dbe66630 100644 --- a/internal/api/controllers/private/highlevelConnectionStatus.go +++ b/internal/api/controllers/private/highlevelConnectionStatus.go @@ -49,6 +49,13 @@ func (this *controllers) ApiInternalHighlevelConnectionStatus(ctx echo.Context) return ctx.NoContent(http.StatusBadRequest) } + if len(hostConnectorDetails) == 0 { + // FIXME: I'm not sure that this is right. Basically, we need to return a response that says the host was not available.... + // This could happen if the host was deleted from inventory or an error (404) came back from inventory + // Think through this a bit more and build a test around this at the API level + return ctx.JSON(http.StatusOK, noRHCResponses) + } + satellite, directConnected, noRhc := sortHostsByRecipient(hostConnectorDetails) // Return noRHC If no Satellite or Direct Connected hosts exist