Skip to content

[Bug] OpenFeatureClient _typecheck_flag_value incorrectly raises type mismatch between int and float #516

@fpiche

Description

@fpiche

Hi there! First of all thank you to the maintainers for OpenFeature, its great :)

I've recently run into an issue where if the flag provider returns an int but the default value of the flag is a float, a TypeMismatchError is raised:

openfeature.exception.TypeMismatchError: Expected type <class 'float'> but got <class 'int'>

This can happen when the flag backend doesn't have float and int types but rather just a "number" type. For example in the Launch Darkly UI, setting a value of 1 results in this error from Openfeature, but 1.000001 works fine. (Note that Launch Darkly doesn't allow float values such as 1.0 they get automatically converted to an int (1), leading to the error)

Would it be possible for Openfeature to gracefully cast integer values to floats?

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