We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
When attempting to parse an environment variable to a Secret[], the pydantic-settings module raises an error.
How to reproduce:
import os from pydantic import PostgresDsn, SecretStr, Secret from pydantic_settings import BaseSettings class Settings(BaseSettings): DSN1: SecretStr DSN2: PostgresDsn DSN3: Secret[PostgresDsn] os.environ["DSN1"] = "postgresql://user:password@localhost/db" os.environ["DSN2"] = "postgresql://user:password@localhost/db" os.environ["DSN3"] = "postgresql://user:password@localhost/db" settings = Settings()
Expected behaviour: DSN3 successfully parsed into Secret[PostgresDsn] type
Actual behaviour: pydantic_settings.sources.SettingsError: error parsing value for field "DSN3" from source "EnvSettingsSource"
pydantic_settings.sources.SettingsError: error parsing value for field "DSN3" from source "EnvSettingsSource"
Additional info: As I understood from the stacktrace, DSN3 is marked as a complex field, and pydantic-settings attempts to parse it from JSON.
The text was updated successfully, but these errors were encountered:
Thanks @zoola969 for reporting this issue.
I will investigate the problem and will prepare a fix.
Sorry, something went wrong.
@zoola969 I created #478 to fix the problem.
Could you please confirm?
@hramezani checked on your branch, works good, thanks
samuelcolvin
Successfully merging a pull request may close this issue.
When attempting to parse an environment variable to a Secret[], the pydantic-settings module raises an error.
How to reproduce:
Expected behaviour:
DSN3 successfully parsed into Secret[PostgresDsn] type
Actual behaviour:
pydantic_settings.sources.SettingsError: error parsing value for field "DSN3" from source "EnvSettingsSource"
Additional info:
As I understood from the stacktrace, DSN3 is marked as a complex field, and pydantic-settings attempts to parse it from JSON.
The text was updated successfully, but these errors were encountered: