From 291551b45c3eb8c86f55a1f1983a7d2e0052f32b Mon Sep 17 00:00:00 2001 From: Gabriel de Souza Seibel Date: Fri, 17 Nov 2023 15:07:22 -0300 Subject: [PATCH] Net 687 : fix license validation failure log (#2675) * On license validation fail, parse and store the message of the response * Return cached response body when necessary * Have license validation return proper val,err * Improve logs readability on lic val error --- pro/license.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pro/license.go b/pro/license.go index 40570575f..52d373809 100644 --- a/pro/license.go +++ b/pro/license.go @@ -237,13 +237,10 @@ func validateLicenseKey(encryptedData []byte, publicKey *[32]byte) ([]byte, erro // at this point the backend returned some undesired state // inform failure via logs - err = fmt.Errorf("could not validate license with validation backend, got status code %d", validateResponse.StatusCode) + body, _ := io.ReadAll(validateResponse.Body) + err = fmt.Errorf("could not validate license with validation backend (status={%d}, body={%s})", + validateResponse.StatusCode, string(body)) slog.Warn(err.Error()) - body, err := io.ReadAll(validateResponse.Body) - if err != nil { - slog.Warn(err.Error()) - } - slog.Warn("license-validation backend response: %s", string(body)) // try to use cache if we had a temporary error if code == http.StatusServiceUnavailable || code == http.StatusGatewayTimeout {