Feature Request: Exception or Warning on Duplicate Configuration Items
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
Research direction
Start by tracing how py-dotenv handles repeated keys while loading a .env file and review the proposed behavior options. Done should be defined by an agreed API and semantics for warning, strict, latter-covers, and any custom merge logic.
Written by the indexing model from the issue text.
Description
Currently, py-dotenv uses a strategy of overwriting with the latter value when handling configuration items with the same key, that is, using the last value of the repeated key. However, I just wasted an entire morning because there were three configuration items with the same key in my .env file. 😢
To avoid others encountering similar issues, I propose adding an optional behavior parameter. The default should be warning, meaning the latter value overwrites the former but with a warning. It could also be set to strict, which throws an exception, or to latter-covers, which means the latter value overwrites the former without any warning.
I have researched how other libraries handle this issue, for reference:
| Parser | Duplicate Handling | Notes |
|---|---|---|
| Node.js dotenv | Latter covers | Most common mode |
| Python dotenv | Latter covers | Configurable to override system variables |
| PHP phpdotenv | Default error | Can be set to allow overrides |
| Ruby dotenv | Latter covers | Issues a warning |
| Go godotenv | Latter covers | No warning |
| Docker Compose | Latter covers | Follows file loading order |
Append: maybe a Callable[[list[str]], str] like sum is also acceptable, for #374 suggests a customed merge logic.
- Dominant language
- Python
- Stars
- 8.9k
- Forks
- 581
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from theskumar/python-dotenv
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
theskumar/python-dotenv#699 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
theskumar/python-dotenv#697 ·
-
Difficulty 5/5 Over a week Newbie friendliness 28/100
theskumar/python-dotenv#693 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
theskumar/python-dotenv#683 · 4 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
theskumar/python-dotenv#644 · 2 comments ·
All issues in theskumar/python-dotenv
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
bancolombia/sentinel#23 ·
-
test md OpenCI
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
integration:quickjs org:external priority:backlog topic:code-interpreter topic:middleware type:feature
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
langchain-ai/deepagents#6450 ·
-
bug client
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100