Flagsmith / flagsmith-go-client

Flagsmith Golang Client
https://www.flagsmith.com/
BSD 3-Clause "New" or "Revised" License
13 stars 13 forks source link

Getting panic invalid memory address or nil pointer dereference in GetIdentitySegments #137

Closed nishant-shah-social closed 1 week ago

nishant-shah-social commented 1 month ago

Hello Team, We are using flagsmith self hosted. The SDK is being used in local evaluation mode. We have been seeing one error with the sdk whenever due to some reason the flagsmith server is unavailable or has some issues for few minutes. The SDK panics on /go/pkg/mod/github.com/!flagsmith/flagsmith-go-client/v3@v3.1.0/flagengine/engine.go in GetIdentitySegments

Below is the stack trace:-

Called from: /go/pkg/mod/github.com/!flagsmith/flagsmith-go-client/v3@v3.1.0/flagengine/engine.go in GetIdentitySegments

Hide 4 more frames
/go/pkg/mod/github.com/!flagsmith/flagsmith-go-client/v3@v3.1.0/flagengine/engine.go in getIdentityFeatureStatesMap at line 96
/go/pkg/mod/github.com/!flagsmith/flagsmith-go-client/v3@v3.1.0/flagengine/engine.go in GetIdentityFeatureStates at line 41
/go/pkg/mod/github.com/!flagsmith/flagsmith-go-client/v3@v3.1.0/client.go in (*Client).getIdentityFlagsFromEnvironment at line 189
/go/pkg/mod/github.com/!flagsmith/flagsmith-go-client/v3@v3.1.0/client.go in (*Client).GetIdentityFlags at line 98

Our expectation is:- Given we are using local evaluation mode, the sdk should not panic even if the flagsmith server has some issues for few minutes. It should keep on serving the flags from last fetched environmentDocument without any problem. Please let us know if this expectation is not correct.

matthewelwell commented 1 month ago

Hi @nishant-shah-social, your expectation is correct - the Golang SDK should continue to serve flags, as long as it has retrieved the environment document on a previous request.

We will investigate this issue further and update once we can.

gagantrivedi commented 1 week ago

@nishant-shah-social The client retains the old environment document in the cache even if the update fails. I am unable to reproduce the error you're encountering.

To further debug this, we'll need the following information:

  1. Please update the client to the latest version.
  2. The full stack trace along with a reproducible example.