Skip to content

Commit

Permalink
Fix nil flag client, and warn about use in future (#4885)
Browse files Browse the repository at this point in the history
  • Loading branch information
evankanderson authored Nov 5, 2024
1 parent 7e6460a commit 45300d5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
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

0 comments on commit 45300d5

Please sign in to comment.