Skip to content

fix: Calling err.Error() on nil error causes panic #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
@@ -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 {
@@ -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)
}
}

6 changes: 4 additions & 2 deletions providers/go-feature-flag/pkg/provider.go
Original file line number Diff line number Diff line change
@@ -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"
@@ -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),
},
}
}
}

Unchanged files with check annotations Beta

)
func Example() {
openfeature.SetProvider(flipt.NewProvider(

Check failure on line 11 in providers/flipt/pkg/provider/example_test.go

GitHub Actions / lint

Error return value of `openfeature.SetProvider` is not checked (errcheck)
flipt.WithAddress("localhost:9000"),
))
unaryInterceptors: []grpc.UnaryClientInterceptor{
// by default this establishes the otel.TextMapPropagator
// registers to the otel package.
otelgrpc.UnaryClientInterceptor(),

Check failure on line 83 in providers/flipt/pkg/service/transport/service.go

GitHub Actions / lint

SA1019: otelgrpc.UnaryClientInterceptor is deprecated: Use [NewClientHandler] instead. (staticcheck)
},
}
address = "passthrough:///" + s.address
}
conn, err := grpc.Dial(

Check failure on line 114 in providers/flipt/pkg/service/transport/service.go

GitHub Actions / lint

SA1019: grpc.Dial is deprecated: use NewClient instead. Will be supported throughout 1.x. (staticcheck)
address,
grpc.WithTransportCredentials(credentials),
grpc.WithBlock(),

Check failure on line 117 in providers/flipt/pkg/service/transport/service.go

GitHub Actions / lint

SA1019: grpc.WithBlock is deprecated: this DialOption is not supported by NewClient. Will be supported throughout 1.x. (staticcheck)
grpc.WithChainUnaryInterceptor(s.unaryInterceptors...),
)
if err != nil {
type Cache struct {
internalCache gcache.Cache
maxEventInMemory int64

Check failure on line 16 in providers/go-feature-flag/pkg/controller/cache.go

GitHub Actions / lint

field `maxEventInMemory` is unused (unused)
ttl time.Duration
disabled bool
}
)
// responderQueue is a type that manages a queue of responders
type responderQueue struct {

Check failure on line 35 in providers/harness/pkg/provider_test.go

GitHub Actions / lint

type `responderQueue` is unused (unused)
responders []httpmock.Responder
index int
}
// newResponderQueue creates a new instance of responderQueue with the provided responders
func newResponderQueue(responders []httpmock.Responder) *responderQueue {

Check failure on line 41 in providers/harness/pkg/provider_test.go

GitHub Actions / lint

func `newResponderQueue` is unused (unused)
return &responderQueue{
responders: responders,
index: 0,
}
// getNextResponder is a method that returns the next responder in the queue
func (q *responderQueue) getNextResponder(req *http.Request) (*http.Response, error) {

Check failure on line 49 in providers/harness/pkg/provider_test.go

GitHub Actions / lint

func `(*responderQueue).getNextResponder` is unused (unused)
if q.index >= len(q.responders) {
// Stop running tests as the input is invalid at this stage.
log.Fatal("Not enough responders provided to the test function being executed")
}
// Same as registerResponders except the auth response can be different per call
func registerMultipleResponseResponders(authResponder []httpmock.Responder, targetSegmentsResponder httpmock.Responder, featureConfigsResponder httpmock.Responder) {

Check failure on line 75 in providers/harness/pkg/provider_test.go

GitHub Actions / lint

func `registerMultipleResponseResponders` is unused (unused)
authQueue := newResponderQueue(authResponder)
httpmock.RegisterResponder("POST", "http://localhost/api/1.0/client/auth", authQueue.getNextResponder)
require.Equal(t, false, resolution.Value)
})
of.SetProvider(provider)

Check failure on line 127 in providers/harness/pkg/provider_test.go

GitHub Actions / lint

Error return value of `of.SetProvider` is not checked (errcheck)
ofClient := of.NewClient("my-app")
evalCtx := of.NewEvaluationContext(