Skip to content

Commit 4c85501

Browse files
fix: Calling err.Error() on nil error causes panic (#579)
Signed-off-by: Daniel Graña <[email protected]> Co-authored-by: Thomas Poignant <[email protected]>
1 parent cc48be1 commit 4c85501

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

providers/go-feature-flag/pkg/controller/goff_api.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ import (
44
"bytes"
55
"encoding/json"
66
"fmt"
7-
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/model"
87
"net/http"
98
"net/url"
109
"path"
10+
11+
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/model"
1112
)
1213

1314
type GoFeatureFlagApiOptions struct {
@@ -104,7 +105,7 @@ func (g *GoFeatureFlagAPI) ConfigurationHasChanged() (ConfigurationChangeStatus,
104105
case http.StatusNotModified:
105106
return FlagConfigurationNotChanged, nil
106107
default:
107-
return ErrorConfigurationChange, err
108+
return ErrorConfigurationChange, fmt.Errorf("request failed with status: %v", response.Status)
108109
}
109110
}
110111

providers/go-feature-flag/pkg/provider.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ package gofeatureflag
33
import (
44
"context"
55
"fmt"
6+
"time"
7+
68
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/controller"
79
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/hook"
810
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/util"
911
"github.com/open-feature/go-sdk-contrib/providers/ofrep"
1012
of "github.com/open-feature/go-sdk/openfeature"
11-
"time"
1213
)
1314

1415
const providerName = "GO Feature Flag"
@@ -245,7 +246,8 @@ func (p *Provider) startPolling(pollingInterval time.Duration) {
245246
p.events <- of.Event{
246247
ProviderName: providerName, EventType: of.ProviderStale,
247248
ProviderEventDetails: of.ProviderEventDetails{
248-
Message: "Impossible to check configuration change " + err.Error()},
249+
Message: fmt.Sprintf("Impossible to check configuration change: %s", err),
250+
},
249251
}
250252
}
251253
}

0 commit comments

Comments
 (0)