From 12d1ae56366a2f2533858dd4d1fb96124a7d299b Mon Sep 17 00:00:00 2001 From: Lukas Zapletal Date: Mon, 9 Oct 2023 17:42:49 +0200 Subject: [PATCH] chore: add extra sources body logging --- internal/clients/http/sources/sources_client.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/clients/http/sources/sources_client.go b/internal/clients/http/sources/sources_client.go index e66d21c6..5f5f3dce 100644 --- a/internal/clients/http/sources/sources_client.go +++ b/internal/clients/http/sources/sources_client.go @@ -77,6 +77,9 @@ func (c *sourcesClient) Ready(ctx context.Context) error { if resp == nil { return fmt.Errorf("ready call: empty response: %w", clients.ErrUnexpectedBackendResponse) } + if resp.JSON400 != nil { + logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx") + } if resp.StatusCode() < 200 || resp.StatusCode() > 299 { return fmt.Errorf("ready call: %w: %d", clients.ErrUnexpectedBackendResponse, resp.StatusCode()) @@ -116,6 +119,9 @@ func (c *sourcesClient) ListProvisioningSourcesByProvider(ctx context.Context, p if resp == nil { return nil, 0, fmt.Errorf("list application types empty response: %w", clients.ErrUnexpectedBackendResponse) } + if resp.JSON404 != nil || resp.JSON400 != nil { + logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx") + } if resp.JSON200 == nil { return nil, 0, fmt.Errorf("list application types returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse) @@ -169,6 +175,9 @@ func (c *sourcesClient) ListAllProvisioningSources(ctx context.Context) ([]*clie if resp == nil { return nil, 0, fmt.Errorf("list provisioning sources empty response: %w", clients.ErrUnexpectedBackendResponse) } + if resp.JSON404 != nil || resp.JSON400 != nil { + logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx") + } if resp.JSON200 == nil { return nil, 0, fmt.Errorf("list provisioning sources returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse) @@ -216,6 +225,9 @@ func (c *sourcesClient) GetAuthentication(ctx context.Context, sourceId string) if resp == nil { return nil, fmt.Errorf("get source authentication empty response: %w", clients.ErrUnexpectedBackendResponse) } + if resp.JSON404 != nil || resp.JSON400 != nil { + logger.Warn().Bytes("body", resp.Body).Int("status", resp.StatusCode()).Msg("Get authentication from sources returned 4xx") + } if resp.JSON200 == nil { return nil, fmt.Errorf("get source authentication returned %d: %w", resp.StatusCode(), clients.ErrUnexpectedBackendResponse) }