python-server-sdk icon indicating copy to clipboard operation
python-server-sdk copied to clipboard

Warning flooding logs

Open ppayun opened this issue 1 year ago • 3 comments

https://github.com/launchdarkly/python-server-sdk/blob/d152455b89cb70164d8487a1cc0b47f92017a5c4/ldclient/client.py#L471

We use default value for some flags, and this logic keep writing warnings to the logs, can the log level be changed to DEBUG?

    if not context.valid:
        log.warning("Context was invalid for flag evaluation (%s); returning default value" % context.error)
        return EvaluationDetail(default, None, error_reason('USER_NOT_SPECIFIED')), None

ppayun avatar Jul 03 '24 16:07 ppayun

This error should only be shown when the context you are providing is considered invalid. Is there a reason you are trying to use an invalid context?

The reason the context is invalid should be in the logged error.

keelerm84 avatar Jul 03 '24 16:07 keelerm84

I just checked, for some reason, the code is using an empty context(see code below). We can definitely add some context info. But still why empty context is illegal and showing as warning?

        context_builder = Context.builder(client_id)

        for dict_key, dict_value in context_dict.items():  # this is empty, we didn't set any values
            context_builder.set(dict_key, dict_value)

        context = context_builder.build()
        value = ldclient.get().variation(key, context, default_value)
        return value

ppayun avatar Jul 08 '24 18:07 ppayun

@ppayun my apologies for the long delay in responding.

Providing a key is a requirement of our context model. We use the provided contexts to populate things like the context drop down list in our UI, and it is also used for aggregating metrics for things like experimentation, etc.

While we do not require many attributes to be set for a context, we do require a key and a valid kind (which will to default to 'user').

keelerm84 avatar Jul 25 '24 19:07 keelerm84

This issue is marked as stale because it has been open for 30 days without activity. Remove the stale label or comment, or this will be closed in 7 days.

github-actions[bot] avatar Aug 25 '24 01:08 github-actions[bot]