Skip to content

Commit

Permalink
fix: Flagsmith provider no key exception (#98)
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Petrusevici <[email protected]>
Signed-off-by: vpetrusevici <[email protected]>
Co-authored-by: Vladimir Petrusevici <[email protected]>
  • Loading branch information
vpetrusevici and Vladimir Petrusevici authored Nov 10, 2023
1 parent 49efdde commit da84a17
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ public FlagsmithProvider(IFlagsmithProviderConfiguration providerOptions, IFlags

private Task<IFlags> GetFlags(EvaluationContext ctx)
{
var key = ctx?.GetValue(Configuration.TargetingKey)?.AsString;
string key = null;
if (ctx != null && ctx.TryGetValue(Configuration.TargetingKey, out var value))
{
key = value?.AsString;
}

return string.IsNullOrEmpty(key)
? _flagsmithClient.GetEnvironmentFlags()
: _flagsmithClient.GetIdentityFlags(key, ctx.AsDictionary().Select(x => new Trait(x.Key, x.Value.AsObject) as ITrait).ToList());
Expand Down

0 comments on commit da84a17

Please sign in to comment.