Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repeating config.load() fails to read default_files #48

Open
roharvey opened this issue Aug 22, 2024 · 2 comments
Open

repeating config.load() fails to read default_files #48

roharvey opened this issue Aug 22, 2024 · 2 comments
Assignees

Comments

@roharvey
Copy link

roharvey commented Aug 22, 2024

If you happen to call config.load() twice, the latter fails to read from default_files. This leads to difficult to troubleshoot issues like:

pydantic_core._pydantic_core.ValidationError: 1 validation error for AppConfig
SECRET_KEY
  Field required [type=missing, input_value={}, input_type=dict]
    For further information visit https://errors.pydantic.dev/2.8/v/missing

This probably is avoidable by very reasonably saying that we shouldn't be calling config.load() twice. However the docs suggest using config.django_manage() which itself calls config.load(), so in that case at least it is unavoidable.

It looks like the method to check for files loaded data in version 5.0 should be updated.

@ipmb
Copy link
Member

ipmb commented Aug 22, 2024

ruamel.yaml is only loaded if a yaml file has been specified as the config file. It is optional in the sense that, if you don't want to load yaml files, you don't need it.

if ext in [".yaml", ".yml"]:
import ruamel.yaml

@roharvey
Copy link
Author

Gotcha! I'll update the ticket

@roharvey roharvey changed the title repeating config.load() fails to read default_files, ruamel.yaml not really optional repeating config.load() fails to read default_files Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants