diff --git a/internal/ldclient/flags.go b/internal/ldclient/flags.go index f501252d..d2843989 100644 --- a/internal/ldclient/flags.go +++ b/internal/ldclient/flags.go @@ -9,6 +9,7 @@ import ( ldapi "github.com/launchdarkly/api-client-go/v13" lcr "github.com/launchdarkly/cr-flags/config" "github.com/launchdarkly/cr-flags/internal/version" + "github.com/pkg/errors" ) func GetAllFlags(config *lcr.Config) ([]ldapi.FeatureFlag, error) { @@ -55,9 +56,11 @@ func getFlags(config *lcr.Config, params url.Values) ([]ldapi.FeatureFlag, error if resp.StatusCode != http.StatusOK { var r interface{} - _ = decoder.Decode(&r) + if err := decoder.Decode(&r); err != nil { + return []ldapi.FeatureFlag{}, errors.Wrapf(err, "unexpected status code: %d. unable to parse response", resp.StatusCode) + } err := fmt.Errorf("unexpected status code: %d with response: %#v", resp.StatusCode, r) - return nil, err + return []ldapi.FeatureFlag{}, err } flags := ldapi.FeatureFlags{}