Skip to content

env_prefix falls back to env vars without prefixΒ #441

@hofrob

Description

@hofrob

Using my example from #437: https://github.com/hofrob/pydantic-settings-env-prefix

If you uv run hello the result is:

hello='ABC'

This value is coming from the first line in .env: HELLO=ABC

I don't think the intention of env_prefix is to just fall back to whatever env var it can find that matches the variable without the prefix. If you have nested or complex settings with multiple API keys managed via different env_prefix values, you'll not want to use an API key with the wrong service. I'd consider this API key compromised.

See also this comment: #437 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions