Skip to content
New issue

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

warn instead of raise for missing env file #2485

Merged
merged 1 commit into from
Feb 6, 2024

Conversation

mathause
Copy link
Contributor

@mathause mathause commented Feb 6, 2024

Summary

Adresses #2422

Let me know if you want a custom Warning and/ or any doc changes.

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

@Kludex
Copy link
Sponsor Member

Kludex commented Feb 6, 2024

Thanks.

@Kludex Kludex merged commit 7ec763c into encode:master Feb 6, 2024
5 checks passed
@mathause mathause deleted the warn_on_missing_env_file branch February 7, 2024 09:23
@mathause
Copy link
Contributor Author

mathause commented Feb 7, 2024

Thanks & sorry for the churn.

@tvasenin
Copy link
Contributor

tvasenin commented Feb 9, 2024

@Kludex Could you pls release the fixed version asap? (maybe even backport to 0.36.x releases, since it's used by latest FastsAPI v0.109.2)

@Kludex
Copy link
Sponsor Member

Kludex commented Feb 9, 2024

@tvasenin Can you open a PR analogous to this: #2457 with 0.37.1?

nixroxursox pushed a commit to nixroxursox/starlette that referenced this pull request Mar 18, 2024
tvasenin added a commit to tvasenin/fastapi that referenced this pull request Mar 19, 2024
v0.36.0 to v0.37.0 had a regression failing on missing .env file.

Fixed in v0.37.1: encode/starlette#2485
br3ndonland added a commit to br3ndonland/fastenv that referenced this pull request Apr 7, 2024
Starlette 0.37 modifies the exception handling behavior of the `Config`
class used for application settings. The `Config` class accepts an
`env_file` arg that can be used to load environment variables from a
"dotenv" (`.env`) file. Previously, if the file was not found, the
`Config` class would silently pass without any exception. In 0.36, the
`Config` class was updated to raise a `FileNotFoundError` exception if
`env_file` was not not found. This was a breaking change but was not
documented as such (encode/starlette#2422, encode/starlette#2446).
In 0.37, the exception handling behavior has been changed again to raise
a warning instead of an exception (encode/starlette#2485), which could
also be a breaking change if users had rewritten their code to catch the
`FileNotFoundError`.

This commit will update the comparisons docs to explain that a warning
will now be raised, and will link to the relevant code changes.
br3ndonland added a commit to br3ndonland/inboard that referenced this pull request Apr 8, 2024
This commit will update/upgrade to
[FastAPI 0.110.1](https://fastapi.tiangolo.com/release-notes/)
and
[Starlette 0.37.2](https://www.starlette.io/release-notes/).
FastAPI 0.110 makes a change to dependencies with `yield` and `except`.
Dependencies must now raise exceptions after `except`. This change is
intended to address memory leak issues and may be a breaking change in
some projects if dependencies with `yield` and `except` used `pass`
instead of `raise`. See the
[FastAPI docs](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/)
for further info. FastAPI 0.110.1 makes a small type annotation change
to the `Depends` dependency class.

Starlette 0.37 modifies the exception handling behavior of the `Config`
class used for application settings. The `Config` class accepts an
`env_file` arg that can be used to load environment variables from a
"dotenv" (`.env`) file. Previously, if the file was not found, the
`Config` class would silently pass without any exception. In 0.36, the
`Config` class was updated to raise a `FileNotFoundError` exception if
`env_file` was not not found. This was a breaking change but was not
documented as such (encode/starlette#2422, encode/starlette#2446).
In 0.37, the exception handling behavior has been changed again to raise
a warning instead of an exception (encode/starlette#2485), which could
also be a breaking change if users had rewritten their code to catch the
`FileNotFoundError`.
See the [fastenv docs](https://fastenv.bws.bio/comparisons#starlette)
for a detailed description of the Starlette `Config` class. Note that
FastAPI updated the Starlette minor version from 0.36 to 0.37 in the
0.110.1 patch release.
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.

None yet

3 participants