Feature flag isEnabled with All Users strategy gives random results

,

Hi there !

I’m trying to use the feature flag feature in the simplest use case possible.

I created a feature flag with All Users as strategy, and no environment specification, which to my understanding resolves to All Environment, as confirmed by the Gitlab UI.

Then, using the following Go code, I want to access the status of the feature flag:

package main

import (
    "os"
    "io"
    "net/http"

    "github.com/Unleash/unleash-client-go"
)

type metricsInterface struct {
}

func init() {
    unleash.Initialize(
        unleash.WithUrl("https://gitlab.com/api/v4/feature_flags/unleash/XXXXXX"),
        unleash.WithInstanceId("XXXXXXXX"),
        unleash.WithAppName("development"),
        unleash.WithListener(&metricsInterface{}),
    )
}

func helloServer(w http.ResponseWriter, req *http.Request) {
    if unleash.IsEnabled("my_feature_flag") {
        io.WriteString(w, "Feature enabled\n")
    } else {
        io.WriteString(w, "hello, world!\n")
    }
}

func main() {
    if unleash.IsEnabled("hybridation_mode") {
        io.WriteString(os.Stdout, "enabled\n")
    } else {
        io.WriteString(os.Stdout, "disabled\n")
    }
}

As a result, when executed multiple times, I’m getting either “disabled” or “enabled” status, almost like its random.

I’m understanding than its related to this “All users” strategy, because if I remove it, then I’ll get always “disabled” as result.

I though that “All users” meant than the status of the feature flag will always be the activation status of this feature flag on the UI interface, and doesn’t depend on anything.

Can someone explain what I’m missing here? Thanks!

Thanks to the Gitlab support, I share here the solution. It was due to the unleash go client version, just change the import line to:

    "github.com/Unleash/unleash-client-go/v3"

And you’ll be on your way.