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

Pydantic fails to read content of files in secrets_dir on Linux #3273

Closed
3 tasks done
dimitri-b opened this issue Sep 28, 2021 · 1 comment · Fixed by #3304
Closed
3 tasks done

Pydantic fails to read content of files in secrets_dir on Linux #3273

dimitri-b opened this issue Sep 28, 2021 · 1 comment · Fixed by #3304
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@dimitri-b
Copy link

Checks

  • I added a descriptive title to this issue
  • I have searched (google, github) for similar issues and couldn't find anything
  • I have read and followed the docs and still think this is a bug

Bug

To reproduce, on Linux OS:

  • build a config manager that subclasses BaseSettings
  • add secrets_dir config pointing to dir with text file(s), as per docs
  • add class attributes to use the files in secrets_dir, as per docs
  • run the code and inspect/print the attributes
  • observe that vars coming from .env file work fine, but those from secrets_dir are None, or error if not Optional, and there is no user warning for the secrets_dir itself

Repeat the same on MacOS - it should work OK, the content is read correctly.

I have added a repo with Dockerfile replicating the setup: https://github.com/dimitri-b/pydantic-secrets-dir-issue

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.8.2
            pydantic compiled: True
                 install path: /usr/local/lib/python3.8/site-packages/pydantic
               python version: 3.8.12 (default, Sep  3 2021, 02:35:42)  [GCC 8.3.0]
                     platform: Linux-5.10.47-linuxkit-x86_64-with-glibc2.2.5
     optional deps. installed: ['dotenv', 'typing-extensions']
import pydantic

class SettingsLocal(pydantic.BaseSettings):
    NORMAL_VAR: Optional[str]
    SECRET_VAR: Optional[str]

    class Config:
        env_file = "./.env"
        secrets_dir = "./secrets-in-project"
...
@dimitri-b dimitri-b added the bug V1 Bug related to Pydantic V1.X label Sep 28, 2021
@dimitri-b dimitri-b changed the title Pydantic fails to read content of files in secret_dir on Linux Pydantic fails to read content of files in secrets_dir on Linux Sep 28, 2021
@grelinfo
Copy link

grelinfo commented Dec 7, 2021

I've got the same bug bug solved with config case_sensitive = True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants