Skip to content
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

Fix nil flag client, and warn about use in future #4885

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions internal/flags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func fromContext(ctx context.Context) openfeature.EvaluationContext {

// Bool provides a simple wrapper around client.Boolean to normalize usage for Minder.
func Bool(ctx context.Context, client openfeature.IClient, feature Experiment) bool {
if client == nil {
zerolog.Ctx(ctx).Debug().Str("flag", string(feature)).Msg("Bool called with <nil> client, returning false")
return false
}
ret := client.Boolean(ctx, string(feature), false, fromContext(ctx))
// TODO: capture in telemetry records
return ret
Expand Down
2 changes: 1 addition & 1 deletion internal/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func AllInOneServerService(
flags.OpenFeatureProviderFromFlags(ctx, cfg.Flags)
featureFlagClient := openfeature.NewClient(cfg.Flags.AppName)

evt, err := eventer.New(ctx, nil, &cfg.Events)
evt, err := eventer.New(ctx, featureFlagClient, &cfg.Events)
if err != nil {
return fmt.Errorf("unable to setup eventer: %w", err)
}
Expand Down