Skip to content

New feature#2

Open
HardikCloudaeye wants to merge 2 commits into
devfrom
new-feature
Open

New feature#2
HardikCloudaeye wants to merge 2 commits into
devfrom
new-feature

Conversation

@HardikCloudaeye

Copy link
Copy Markdown
Owner

No description provided.

Comment thread src/dotenv/main.py
Comment on lines +346 to +348
with open(dotenv_path or '.env') as f:

content = f.read()

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review #1

License
License

Issue:

FileNotFoundError: stream argument ignored

Where:

load_dotenv in src/dotenv/main.py

Description:

stream-based loading breaks when dotenv_path is None and no .env exists
New code removed prior stream-based behavior and now unconditionally executes open(dotenv_path or '.env') at src/dotenv/main.py:346-348. The function signature still accepts stream at src/dotenv/main.py:323, but the new implementation never uses it. Evidence-1 shows the previous implementation passed stream=stream into DotEnv and only fell back when both dotenv_path and stream were None, so this is a new API/behavior regression that can raise FileNotFoundError for stream-only callers.


+    with open(dotenv_path or '.env') as f:
+
+        content = f.read()

Feedback: 👎

Comment thread src/dotenv/main.py
Comment on lines +361 to +363
if line.strip() and not line.startswith('#'):

key, value = line.split('=', 1)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review #2

License
License

Issue:

ValueError: malformed .env line crashes parser

Where:

parse_dotenv in src/dotenv/main.py

Description:

loading crashes when a non-comment line lacks an equals sign
New parser code only skips blank/comment lines at src/dotenv/main.py:361, then unconditionally executes line.split('=', 1) at line 363. A non-comment malformed line without = raises ValueError, and the only traced caller load_dotenv passes raw file content directly from open(...).read() to parse_dotenv with no validation or exception handling at src/dotenv/main.py:346-350.


+            key, value = line.split('=', 1)

Feedback: 👎

Comment thread src/dotenv/validator.py
Comment on lines +25 to +30
try:

schema['type'](value)
except ValueError:

raise ValueError(f"Invalid type for {var_name}: {value}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review theskumar#3

License
License

Issue:

TypeError escapes for invalid schema type callables

Where:

EnvValidator.validate in src/dotenv/validator.py

Description:

validation crashes when schema type is a callable like bool(None) replacement raising TypeError
New file in this PR. EnvValidator.validate wraps schema['type'](value) in try/except but catches only ValueError at src/dotenv/validator.py:25-30. The schema callable is caller-controlled via add_schema(..., var_type, ...) at src/dotenv/validator.py:8-13, so a callable that raises TypeError will escape unhandled. No broader enclosing handler is present in the function.


+            try:
+
+                schema['type'](value)
+            except ValueError:

Feedback: 👎

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant