Skip to content

EnvSettingsSource get_field_value returns field_name instead of the env name. #504

@atti92

Description

@atti92

In 2.7.0 get_field_value returns the field_name instead of the env name, we depended on this logic, but now it makes it really hard to figure out which environment variable was used.

Can we have the env_name added back to EnvSettingsSource to look up the value?

I can see why the change was made, and it makes sense, but we are loosing data with it. We were using it to give feedback for users to track each configuration's value's source. eg.: conf.value1 -> $MY_ENVVAR, conf.value2 -> .env/VALUE2, etc...

Code block in question:

        for field_key, env_name, value_is_complex in field_infos:
            env_val = self.env_vars.get(env_name)
            if env_val is not None:
                if value_is_complex or (self.config.get('populate_by_name', False) and (field_key == field_name)):
                    preferred_key = field_key
                break

        return env_val, preferred_key, value_is_complex

We are also fine if env_name is saved somewhere inside the class to lookup later.

Metadata

Metadata

Assignees

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