Error getting boolean flag

Hey Flipt folks!

I’m integrating Flipt in our FastAPI backend using gRPC. Everything works fine but I have a problem getting a boolean flag. I’m building a service class with a method similar to this:

def evaluate_bool(self, flag_key: str, entity_id: str) -> bool:
        client = self.get_client() # This create a channel with an interceptor that inject the AuthToken, and return the Flipt Stub
        response = client.Evaluate(
            EvaluationRequest(
                flag_key=flag_key,
                entity_id=entity_id,
                context={},
                namespace_key=app_settings.FLIPT_NAMESPACE,
            ),
        )
        ...

If the flag_key is a variant, the response is expected depending on the entity_id. But if the flag is a boolean, I’m getting this error:

grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "flag type BOOLEAN_FLAG_TYPE invalid"
        debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-09-11T13:55:10.76349593+00:00", grpc_status:3, grpc_message:"flag type BOOLEAN_FLAG_TYPE invalid"}"

This is my configuration:

version: "1.4"
namespace:
  key: production
  name: Production
flags:
- key: test-key
  name: test-sync-edited
  type: BOOLEAN_FLAG_TYPE
  enabled: false
  rollouts:
  - segment:
      key: internal-users
      value: true
- key: another-thing
  name: another-thing
  type: VARIANT_FLAG_TYPE
  enabled: true
  variants:
  - default: true
    key: t1
  - key: t2
  rules:
  - segment: internal-users
    distributions:
    - variant: t2
      rollout: 100
- key: boolean-flag
  name: Boolean Flag
  type: BOOLEAN_FLAG_TYPE
  enabled: false
segments:
- key: internal-users
  name: internal-users
  constraints:
  - type: ENTITY_ID_COMPARISON_TYPE
    property: entityId
    operator: eq
    value: leo.david
  match_type: ALL_MATCH_TYPE

The flag that I’m using and getting the error is test-key. I noticed that the enabled field is False, but I can’t change it in the UI, I don’t see any button.

Flipt is a great platform! Thank you so much for building it!

1 Like

Hey @leonardo ! Sorry you’re running into issues.

This looks like it is using our older Evaluation API, which only support variant type flags. There is a new evaluation specific protobuf set of definitions to generate from, if you want to go this way:

In this situation, you need to use the Boolean specific evaluation RPC.

Are you using one of our pre-built clients? or something hand generated?

Hey @george!

I see the issue now :face_with_hand_over_mouth:. I’m installing the proto definitions from buf using:

pip install flipt-io-flipt-grpc-python --extra-index-url https://buf.build/gen/python
pip install flipt-io-flipt-protocolbuffers-python --extra-index-url https://buf.build/gen/python

But in the Python definitions, I don’t see any EvaluationService. Are that dependencies updated? Where I can find that pre-built clients?

Thanks in advance for your help!

Ahh amazing, let me find out if we can get these other APIs published to buf too.

We have a range of clients in different languages. The main repos are:
Server-Side Eval: GitHub - flipt-io/flipt-server-sdks: Flipt Server-Side SDKs
Client-Side Eval: GitHub - flipt-io/flipt-client-sdks: Flipt Client-Side Evaluation SDKs

The client-side evaluators run evaluations in your application, so no network hop in your code FYI. These are the most performant ones for your application.

The server-side SDKs mostly support HTTP only (apart from Go).

1 Like

So we are publishing the evaluation API to buf, but I am unsure how to get the magic python install for just this sub package:

Hey George! Sorry for my late response. I changed our implementation to use the Python Client-Side lib, and it works really fine! Great use of FFI!

Thank you so much for your help!

2 Likes

That is great to hear @leonardo ! Let us know how well you get on with it.

If you’re interested too, we just launched our cloud product (https://flipt.cloud), which works with or without (you decide) the open-source version. If that happens to pique your interest, we would love your feedback!