-
-
Notifications
You must be signed in to change notification settings - Fork 7.4k
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
remove ujson dependency (it is dead) #820
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
Comments
I would be in favor of recommending I recall the creator of To the extent that there is any difference in json encoding/decoding between json and orjson (or ujson and orjson), it would probably be best to document it. I'd be willing to review a PR making this change (including updates to the docs). (I'd leave the ultimate decision about merging to @tiangolo though.) |
Yeah, I've been intending to do it for quite some time now... 😅 In fact, you can sort of do it right now (and since several versions ago). Here's my plan: I want to export everything from Starlette, to avoid confusions of the type "do I import this from FastAPI or from Starlette?", I've seen reports of that and even I've struggled with that. For example, FastAPI has its own With that, I want to have a response In fact, I added tests for creating custom responses (as part of a PR), testing specifically creating orjson responses: https://github.com/tiangolo/fastapi/blob/f803c77515662cd2382674d9fc8df1e6641b3ba7/tests/test_default_response_class.py#L9-L13 app = FastAPI(default_response_class=ORJSONResponse) Also, as a side note, UJSON is not really used by default anywhere. It's optional, and you would have to use the |
Well, that's elegant sir 🙇♂️ 👏 .
Then I don't understand why it's in requirements. It's written that it's an optional dependency for Pydantic, but it seems that Pydantic has already moved away from ujson here. Seems that their requirements nor setup.py don't have it anymore. |
@hnykda the “all” set of requirements there includes everything necessary to make use of all documented features, including those that are optional. It is intended more for development/reference purposes than for use by consumers. |
Ah, got it! Thanks. I believe this can be closed then. Personally, I would not reference any obsolete dependencies in my project even if they are optional (especially "future-looking" like Python 3.6+, latest libs, ...) . Reasons for that: helping the community to get rid dangerous/old/unmaintained libs and to avoid possibly repealing people who do not like to install stuff which are referencing such unmaintained projects. |
Apparently, https://pypi.org/project/ujson/ and repo seems active again. Just mentioning this. Dunno which one is the better lib. |
Nevermind, apparently |
Just to mention, installing fastapi on windows platform (python 3.9) fails, since orjson neither provide the compatible wheel nor could be compiled. |
On Debian stable installing orjson currently fails because it targets In this case running |
@ahmadazizi, |
Since Starlette dropped support for This require changes in #2335, since it re-adds |
Update fastapi to latest This will revert PR: #35 fastapi still depends on the older ujson version. Issue with remove ujson is tracked in: fastapi/fastapi#820
Regarding ujson, there is a security alert reported with moderate severity which is patched in 5.1.0. Fastapi 0.74.0 requires |
Hello all, I did find a workaround which allows us to build images without the ujson. I am using the FastAPI is fantastic so far, thank you all for your hard work on this project. Here, roughly the steps I used:
Hope this helps someone until they scan make the permanent fix. Thank you, ~ melt |
We can use orjson in most cases: fastapi/fastapi#820
- Update default_response_class to ORJSONResponse. - Remove the ujson dependency as it's deprecated. - Remove install [all] with fastapi - Explicitly add dependency packages for Pydantic and Starlette - Update FastAPI to latest version 0.75.0 - Lock stomp.py to 7.0.0 as 8.0.0 broke the app This fixes ujson CVE-2021-45958. This is related to: fastapi/fastapi#820 Signed-off-by: Wayne Sun <gsun@redhat.com>
Are you sure the ujson is EOL? According to its repository, the last release was in mid-September, and the last commit was 3 weeks ago - the project seems to be quite alive. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Uh oh!
There was an error while loading. Please reload this page.
FastAPI is using
ujson
which has not been actively developed for about 3 years by now. Here is a relevant issue. It's starting to be problematic to actually compileujson
on newer platforms.Possible alternative maybe
orjson
.The text was updated successfully, but these errors were encountered: