fix(marshmallow): add compatibility layer for Flask-AppBuilder with marshmallow 4.x #35920
+315
−25
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.
SUMMARY
Upgrades marshmallow version to >= 4.0
KeyErrorduring schema initialization.Schema._init_fieldsmethod to detect missing fields that Flask-AppBuilder 5.0.0 auto-generates, and then adds these missing fields dynamically as raw fields with appropriate flags & retry initialization until all missing fields are resolved.marshmallow_fix.pymodule, whose job is to specifically address the Flask-AppBuilder 5.0.0 incompatibility with marshmallow 4.x, and thensuperset_config.pyapplies the patch by importing it frommarshmallow_fix.py.superset_config.pyandmarshmallow_fix.pyare minor convention/syntax changes that are required for the Marshmallow upgrade to >= 4.0.0 (See https://marshmallow.readthedocs.io/en/stable/upgrading.html for more info)BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
BEFORE: Upon pinning

marshmallow>=4inpyproject.tomland initializing the superset app, an initialization error occurs.AFTER: App runs without error

TESTING INSTRUCTIONS
Start superset application, see that no marshmallow related errors show up.
Run tests with
docker compose run --rm superset python -m pytest tests/unit_tests/test_marshmallow_compatibility.py -vUnit tests created:
ADDITIONAL INFORMATION
marshmallow>=4.0.0#33162Credit to
@Austin-X @Eyang0612 @PDOracle @MasahisaSekita