Skip to content

Uncaught TypeError: Hydrating FeatureFlag from Redis  #80

Closed
@pierswarmers

Description

@pierswarmers

We start picking up these errors:

Uncaught TypeError: Argument 10 passed to LaunchDarkly\FeatureFlag::__construct() must be of the type array, null given, called in /var/www/alice/vendor/launchdarkly/launchdarkly-php/src/LaunchDarkly/FeatureFlag.php on line 67

We are using the LD Relay to write into Redis, from which the client gets it's flags.

Looking at the Redis data we can see that under some conditions the variations are null. In those cases, it seems that the flag has been inherited in a primative and deleted state.

In any case, this is where the problem hits:

.../LaunchDarkly/FeatureFlag.php:54

    public static function getDecoder() {
        return function ($v) {
            return new FeatureFlag(
                $v['key'],
                $v['version'],
                $v['on'],
                array_map(Prerequisite::getDecoder(), $v['prerequisites'] ?: []),
                $v['salt'],
                array_map(Target::getDecoder(), $v['targets'] ?: []),
                array_map(Rule::getDecoder(), $v['rules'] ?: []),
                call_user_func(VariationOrRollout::getDecoder(), $v['fallthrough']),
                $v['offVariation'],
                $v['variations'], // <-------- I'm broken if null!
                $v['deleted']);
        };
    }

This small change will allow the FeatureFlag to be hydrated (happy to PR that change).

    public static function getDecoder() {
        return function ($v) {
            return new FeatureFlag(
                $v['key'],
                $v['version'],
                $v['on'],
                array_map(Prerequisite::getDecoder(), $v['prerequisites'] ?: []),
                $v['salt'],
                array_map(Target::getDecoder(), $v['targets'] ?: []),
                array_map(Rule::getDecoder(), $v['rules'] ?: []),
                call_user_func(VariationOrRollout::getDecoder(), $v['fallthrough']),
                $v['offVariation'],
                $v['variations'] ?: [],
                $v['deleted']);
        };
    }

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