Skip to content

[18.0] [FIX] fastapi: support both starlette < and >= 0.48#572

Merged
OCA-git-bot merged 1 commit into
OCA:18.0from
camptocamp:18.0-fix-fastapi-bump-version
Nov 5, 2025
Merged

[18.0] [FIX] fastapi: support both starlette < and >= 0.48#572
OCA-git-bot merged 1 commit into
OCA:18.0from
camptocamp:18.0-fix-fastapi-bump-version

Conversation

@ivantodorovich

@ivantodorovich ivantodorovich commented Oct 31, 2025

Copy link
Copy Markdown
Contributor

Recent merged changes in a5bae2b changed status.HTTP_422_UNPROCESSABLE_ENTITY to status.HTTP_422_UNPROCESSABLE_CONTENT in order to supress a deprecation warning emitted by the starlette >= 0.48 library.

However, older versions of starlette will simply break with this change.

Module 'starlette.status' has no attribute 'HTTP_422_UNPROCESSABLE_CONTENT'.
Did you mean: 'HTTP_422_UNPROCESSABLE_ENTITY'?

For this reason, we bump the minimum required version of fastapi to 0.120.0, which consumes newer versions of starlette where this is not an issue.

To be compatible with past and future versions, we simply use the integer value 422, aligning also with the updated fastapi documentation:

See:

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @lmignon,
some modules you are maintaining are being modified, check this out!

@ivantodorovich ivantodorovich force-pushed the 18.0-fix-fastapi-bump-version branch from 1661881 to 6bc3764 Compare October 31, 2025 18:53

@lmignon lmignon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@ivantodorovich IMO We should revert the change related to status.HTTP_422_UNPROCESSABLE_ENTITY to support the same range of starlette version as in fastapi "starlette>=0.40.0,<0.50.0". The depreciation has been introduced in starlette 0.48....

@ivantodorovich

Copy link
Copy Markdown
Contributor Author

Hi @lmignon !

What I don't like about that is that we will hit this issue in the future, at some point. Today it's a deprecation warning, but soon will be an exception.

But I see your point wanting to support older versions, too.. so perhaps we could do the same fastapi did in their project:

That is, replace the use of these constants with their simple integer value (e.g.: 422).
Or, maybe more elegantly, use the correct one depending on the starlette package version.

I'll update this PR with a new proposal

Starting from `starlette >= 0.48`, the `status.HTTP_422_UNPROCESSABLE_ENTITY`
emits a deprecation warning, as it has been replaced by
`status.HTTP_422_UNPROCESSABLE_CONTENT`.

To be compatible with past and future versions, we simply use the integer value
`422`, aligning also with the updated `fastapi` documentation:

See:
- fastapi/fastapi#14077
@ivantodorovich ivantodorovich force-pushed the 18.0-fix-fastapi-bump-version branch from 6bc3764 to 4c44017 Compare November 3, 2025 12:40
@ivantodorovich ivantodorovich changed the title [18.0] [FIX] fastapi: bump required version to 0.120.0 [18.0] [FIX] fastapi: support both starlette < and >= 0.48 Nov 3, 2025
@ivantodorovich

Copy link
Copy Markdown
Contributor Author

@lmignon when you have a moment, please check the new proposal 🙏🏻
Thanks!

@lmignon

lmignon commented Nov 3, 2025

Copy link
Copy Markdown
Contributor

Thank you @ivantodorovich. This fix is pragmatic and solve the issue without introducing additional constrain.

@lmignon

lmignon commented Nov 5, 2025

Copy link
Copy Markdown
Contributor

/ocabot merge patch

@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hey, thanks for contributing! Proceeding to merge this for you.
Prepared branch 18.0-ocabot-merge-pr-572-by-lmignon-bump-patch, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 6d42e07 into OCA:18.0 Nov 5, 2025
7 checks passed
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Congratulations, your PR was merged at 62b5c7e. Thanks a lot for contributing to OCA. ❤️

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants