Fix Flask 3 boot crash by porting the JSON encoder to the provider API - #29
Open
Bungeetaco wants to merge 1 commit into
Open
Fix Flask 3 boot crash by porting the JSON encoder to the provider API#29Bungeetaco wants to merge 1 commit into
Bungeetaco wants to merge 1 commit into
Conversation
flask.json.JSONEncoder was removed in Flask 3; rebase AmiiboJSONEncoder on flask.json.provider.DefaultJSONProvider and register it via app.json. Needed to run on Python 3.14 where Flask 2.x no longer works.
Member
|
If we ever need to reinstall the server again, ill circle back to this. Thanks. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When #6 bumped Flask to 3.1.3 the app stopped booting, and #22 pinned things back to Flask 2.2.5 + Werkzeug 2.3.8 to get workers up again. The actual root cause is that flask.json.JSONEncoder and app.json_encoder were removed in newer Flask, so importing AmiiboJSONEncoder crashes every gunicorn worker on boot.
This ports the encoder to the JSON provider API instead:
The provider API has been around since Flask 2.2, so nothing changes on the currently pinned 2.2.5. It just makes a Flask 3 upgrade possible again whenever you want it. That also matters for newer Python, since Flask 2.2.5 does not run on 3.14 at all (pkgutil.get_loader is gone).
I have been running this self-hosted on Flask 3.1 / Python 3.14 with gunicorn and the full database serves fine, including the custom encoded fields (hex IDs, release dates, collections).