From 7312f2c245eaf42df9393c8b9dbe48285e14d4bf Mon Sep 17 00:00:00 2001 From: Piotr Date: Mon, 26 Oct 2026 12:26:43 +0100 Subject: [PATCH 1/3] Support marshmallow 4. Switch to marshmallow>=4.0.0 and marshmallow-jsonapi-minfork. Marshmallow 4 raises TypeError instead of AttributeError when serializing invalid data, so catch TypeError in resource GET handlers to keep returning JSON:API errors. Co-Authored-By: Claude Opus 5.5 --- base_requirements.txt | 4 ++-- flask_jsonapi/resources.py | 4 ++-- tests/test_integration.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base_requirements.txt b/base_requirements.txt index 76d1f1a..b01c93b 100644 --- a/base_requirements.txt +++ b/base_requirements.txt @@ -1,3 +1,3 @@ Flask -marshmallow>=3.0.0,<4.0.0 -marshmallow_jsonapi +marshmallow>=4.0.0 +marshmallow-jsonapi-minfork diff --git a/flask_jsonapi/resources.py b/flask_jsonapi/resources.py index 06531af..1c71063 100644 --- a/flask_jsonapi/resources.py +++ b/flask_jsonapi/resources.py @@ -70,7 +70,7 @@ def get(self, *args, **kwargs): data = self.schema(include_data=include_fields, only=sparse_fields).dump(resource) except marshmallow.ValidationError as e: raise exceptions.JsonApiException(detail='marshmallow.ValidationError', source=e.messages) - except (AttributeError, KeyError, ValueError) as e: + except (AttributeError, KeyError, TypeError, ValueError) as e: logger.error( 'Error Processing Request', extra={'status_code': http.HTTPStatus.BAD_REQUEST, 'request': request, 'exception': e} @@ -134,7 +134,7 @@ def get(self, *args, **kwargs): many=True, include_data=include_fields, only=sparse_fields).dump(objects_list) except marshmallow.ValidationError as e: raise exceptions.JsonApiException(detail='marshmallow.ValidationError', source=e.messages) - except (AttributeError, KeyError, ValueError) as e: + except (AttributeError, KeyError, TypeError, ValueError) as e: logger.error( 'Error Processing Request', extra={'status_code': http.HTTPStatus.BAD_REQUEST, 'request': request, 'exception': e} diff --git a/tests/test_integration.py b/tests/test_integration.py index f21950e..269531d 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -145,7 +145,7 @@ def test_bad_data_get_list(app): ) result = json.loads(response.data.decode('utf-8')) assert result['errors'][0]['status'] == 500 - assert result['errors'][0]['detail'] == "'int' object has no attribute 'isoformat'" + assert 'isoformat' in result['errors'][0]['detail'] def test_bad_data_get_detail(app): @@ -160,7 +160,7 @@ def test_bad_data_get_detail(app): ) result = json.loads(response.data.decode('utf-8')) assert result['errors'][0]['status'] == 500 - assert result['errors'][0]['detail'] == "'int' object has no attribute 'isoformat'" + assert 'isoformat' in result['errors'][0]['detail'] def test_create_with_missing_data(app): From 2a2db9b62547412d491a9bdb79a6c1293fc770ce Mon Sep 17 00:00:00 2001 From: Piotr Date: Mon, 26 Oct 2026 12:27:32 +0100 Subject: [PATCH 2/3] Update changelog. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 722c794..c208af3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ ## 1.4.2 (unreleased) --------------------- -- Nothing changed yet. +- Support marshmallow 4.0 and switch to marshmallow-jsonapi-minfork. +- Return JSON:API errors when schema serialization raises TypeError. ## 1.4.1 (2026-02-02) From e3672221a9de002f7cbb9929c2a92b02ff8fc632 Mon Sep 17 00:00:00 2001 From: Piotr Date: Mon, 26 Oct 2026 12:28:07 +0100 Subject: [PATCH 3/3] Bump version to 1.5.0.dev0. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c208af3..d3f5543 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.4.2 (unreleased) +## 1.5.0 (unreleased) --------------------- - Support marshmallow 4.0 and switch to marshmallow-jsonapi-minfork. diff --git a/setup.py b/setup.py index 02aa711..8bba253 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ def get_long_description(): setup( name='flask-jsonapi', - version='1.4.2.dev0', + version='1.5.0.dev0', description='JSONAPI 1.0 implementation for Flask.', long_description=get_long_description(), long_description_content_type='text/markdown',