Skip to content

Commit

Permalink
Net 687 : fix license validation failure log (#2675)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
gabrielseibel1 authored Nov 17, 2023
1 parent 82bbf92 commit 291551b
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pro/license.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 291551b

Please sign in to comment.