Skip to content

Commit

Permalink
fix: handling of missing targeting key for shorthand fractional
Browse files Browse the repository at this point in the history
Signed-off-by: Cole Bailey <[email protected]>
  • Loading branch information
colebaileygit committed Apr 2, 2024
1 parent dc64304 commit 7e57fd4
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ def fractional(data: dict, *args: JsonLogicArg) -> typing.Optional[str]:
else:
seed = data.get("$flagd", {}).get("flagKey", "")
targeting_key = data.get("targetingKey")
if not targeting_key:
logger.error("No targetingKey provided for fractional shorthand syntax.")
return None
bucket_by = seed + targeting_key

if not bucket_by:
logger.error("No hashKey value resolved")
return None

hash_ratio = abs(mmh3.hash(bucket_by)) / (2**31 - 1)
Expand Down

0 comments on commit 7e57fd4

Please sign in to comment.