Skip to content

ArgumentError: expected binary but got :null in progressive rollout evaluation #152

@sinakarimi

Description

@sinakarimi

Describe the bug
The Erlang SDK crashes with an ArgumentError during binary construction when evaluating feature flags that have progressive rollout enabled. The error occurs because the rollout evaluation process receives a :null atom instead of a binary value when attempting to hash context attributes for bucket assignment.

To reproduce

  1. Create a feature flag with progressive rollout enabled in LaunchDarkly
  2. Configure the flag to use context attributes for rollout evaluation
  3. Attempt to evaluate the flag using the Erlang SDK when some context attributes are null or missing
  4. The SDK will crash during the rollout evaluation process

Expected behavior
The SDK should handle progressive rollout evaluation gracefully, even when context values are null or missing. It should either use default values, skip null attributes, or provide appropriate fallback behavior without crashing.

Logs

*** (EXIT) an exception was raised: 
    (ArgumentError) construction of binary failed: 
    segment 3 of type 'binary': expected a binary but got: :null
    (ldclient 3.7.0) /app/deps/ldclient/src/ldclient_rollout.erl:157: :ldclient_rollout.bucket_context_value/4
    (ldclient 3.7.0) /app/deps/ldclient/src/ldclient_rollout.erl:84: :ldclient_rollout.rollout_context/3
    (ldclient 3.7.0) /app/deps/ldclient/src/ldclient_eval.erl:547: :ldclient_eval.flag_for_context_variation_or_rollout/6
    (ldclient 3.7.0) /app/deps/ldclient/src/ldclient_eval.erl:340: :ldclient_eval.flag_for_context/5
    (ldclient 3.7.0) /app/deps/ldclient/src/ldclient_eval.erl:258: anonymous fn/4 in :ldclient_eval.all_flags_eval/4
    (stdlib 4.3.1.6) lists.erl:1355: :lists.foldl_1/3
    (ldclient 3.7.0) /app/deps/ldclient/src/ldclient_eval.erl:261: :ldclient_eval.all_flags_eval/4

SDK version
3.7.0

Language version, developer tools
Elixir 1.17.x with OTP 25

Additional context
N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions