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

FastAPI version validation needs improvements #432

Closed
ayharano opened this issue Jul 1, 2023 · 9 comments · Fixed by #433
Closed

FastAPI version validation needs improvements #432

ayharano opened this issue Jul 1, 2023 · 9 comments · Fixed by #433
Assignees
Milestone

Comments

@ayharano
Copy link
Contributor

ayharano commented Jul 1, 2023

I was testing FastAPI 0.100.0-beta2 with Pydantic 2.0 released today and after a few adjustments, when I ran my test suite, it triggered an error due to

if fastapi.__version__ < self.min_version:

I triggered ipdb just before that line and it failed because the displayed line does a string-based comparison, not a proper SemVer comparison

ipdb> self.min_version
'0.41.0'
ipdb> fastapi.__version__
'0.100.0-beta2'
ipdb> fastapi.__version__ < self.min_version  # due to lexicographic comparison, not proper SemVer comparison
True

This issue will be perceived as soon as FastAPI 0.100.0 version is released and projects with pyrollbar use an unpinned version of FastAPI.

@cforcey
Copy link

cforcey commented Jul 12, 2023

This is impacting us as well. Thanks @ayharano for reporting it.

@josephgruber
Copy link

I can confirm this does manifest itself with FastAPI v0.100.0. Using the "add_to" method the following error is thrown:

rollbar.contrib.fastapi.utils.FastAPIVersionError: FastAPI 0.41.0+ is required to use add_to() function

Downgrading to FastAPI 0.99.1 resolves the error.

@danielmorell danielmorell self-assigned this Jul 22, 2023
@cforcey
Copy link

cforcey commented Jul 26, 2023

Thanks @danielmorell for looking into this! This continues to block our upgrade path for fast-api 0.100+ versions.

@johnchristopherjones
Copy link

In rollbar.cotnrib.fastapi.utils, the following check appears:

            if fastapi.__version__ < self.min_version:

A robust quick fix is to use Version from PyPA's packaging, which is already a dependency of pytest.

from packaging.version import Version
...
            if Version(fastapi.__version__) < Version(self.min_version):

Or, since we know FastAPI uses PyPA-compatible versioning, we can be hacky:

            if fastapi.__version__.split(".", 2) < self.min_version.split(".", 2):

@miska-ship-it
Copy link

Any news on this? It is blocking all our projects from updating properly.

@danielmorell
Copy link
Collaborator

This was released in the v1.0.0 beta.

@josephgruber
Copy link

Any word when 1.0.0 will be released (non-beta)?

@ghost
Copy link

ghost commented Nov 14, 2023

Hey @josephgruber, 1.0.0 is planned to be released in 1-2 weeks at latest.

@danielmorell
Copy link
Collaborator

Version 1.0.0 is out now!

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 a pull request may close this issue.

6 participants