statsig-io / go-sdk

A golang SDK for interfacing with Statsig Feature Gates, Dynamic Configs, and A/B Experiments
ISC License
8 stars 10 forks source link

No error when key is invalid #3

Closed victorhurdugaci closed 1 year ago

victorhurdugaci commented 3 years ago

I was trying the Go SDK and by mistake I copied the server secret key without the last character. It took me 10-15 min to figure out why my gate always evaluated to false since there's no error to indicate that the key is invalid.

Here's the code to repro:

client := statsig.New("secret-ThisIsNotMySecretKey")
g := client.CheckGate(statsigtypes.StatsigUser{
    UserID: "hello-o1",
}, "victor_gate_1")
fmt.Println(g) // Prints false

statsigtypes is statsigtypes "github.com/statsig-io/go-sdk/types"

roim commented 3 years ago

Thanks Victor! We'll get this fixed soon.

jkw-statsig commented 3 years ago

Thanks for the feedback! We aren't throwing errors in scenarios like this because we want to make sure we don't crash our users' apps/servers, so we decided to return the default values instead. I agree this is making debugging hard though, so for actionable errors like this, maybe we can print error messages in the console instead?

victorhurdugaci commented 3 years ago

I agree, panic would not be the right thing to do. A console message is a reasonable compromise -- that's what the Sentry SDK does.

Cheers and thanks for the very fast responses!