Skip to content

Commit

Permalink
fix: Calling err.Error() on nil error causes panic (#579)
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Graña <dangra@gmail.com>
Co-authored-by: Thomas Poignant <thomas.poignant@gofeatureflag.org>
  • Loading branch information
dangra and thomaspoignant authored Sep 10, 2024
1 parent cc48be1 commit 4c85501
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 3 additions & 2 deletions providers/go-feature-flag/pkg/controller/goff_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/model"
"net/http"
"net/url"
"path"

"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/model"
)

type GoFeatureFlagApiOptions struct {
Expand Down Expand Up @@ -104,7 +105,7 @@ func (g *GoFeatureFlagAPI) ConfigurationHasChanged() (ConfigurationChangeStatus,
case http.StatusNotModified:
return FlagConfigurationNotChanged, nil
default:
return ErrorConfigurationChange, err
return ErrorConfigurationChange, fmt.Errorf("request failed with status: %v", response.Status)
}
}

Expand Down
6 changes: 4 additions & 2 deletions providers/go-feature-flag/pkg/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package gofeatureflag
import (
"context"
"fmt"
"time"

"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/controller"
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/hook"
"github.com/open-feature/go-sdk-contrib/providers/go-feature-flag/pkg/util"
"github.com/open-feature/go-sdk-contrib/providers/ofrep"
of "github.com/open-feature/go-sdk/openfeature"
"time"
)

const providerName = "GO Feature Flag"
Expand Down Expand Up @@ -245,7 +246,8 @@ func (p *Provider) startPolling(pollingInterval time.Duration) {
p.events <- of.Event{
ProviderName: providerName, EventType: of.ProviderStale,
ProviderEventDetails: of.ProviderEventDetails{
Message: "Impossible to check configuration change " + err.Error()},
Message: fmt.Sprintf("Impossible to check configuration change: %s", err),
},
}
}
}
Expand Down

0 comments on commit 4c85501

Please sign in to comment.