diff --git a/CHANGELOG.md b/CHANGELOG.md index 722c794..d3f5543 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,8 @@ -## 1.4.2 (unreleased) +## 1.5.0 (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) 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/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', 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):