theskumar / theskumar/python-dotenv

AssertionError when attempting to locate dotenv file

Open
#499 7 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
8.9k
Forks
581
PR merge metrics
No merged PRs in 30d

Description

Hello,

I updated to the latest python-dotenv version (1.0.1) this morning and am now starting to see the following Assertion Errors:

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
<>
  File "/usr/local/lib/python3.11/site-packages/dotenv/main.py", line 305, in find_dotenv
    assert frame.f_back is not None
           ^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError

The code that generated the above looks like the following:

if path := find_dotenv(raise_error_if_not_found=False):
  load_dotenv()

Please let me know if there are any other logs or data I can provide to help the debugging/investigation process

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with dotenv/main.py at find_dotenv, especially the assertion at line 305, and reproduce the shown call on Python 3.11 with python-dotenv 1.0.1. Done means locating the cause of the AssertionError and verifying that the reported invocation handles the missing dotenv-file case without raising it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.