Skip to content
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

Error in marshalling can cause a TypeError #75

Closed
robyoung opened this issue Mar 9, 2020 · 0 comments
Closed

Error in marshalling can cause a TypeError #75

robyoung opened this issue Mar 9, 2020 · 0 comments
Labels
bug Something isn't working

Comments

@robyoung
Copy link
Contributor

robyoung commented Mar 9, 2020

Code

from flask_restx import Model, marshal, fields

model = Model('Test', {'field': fields.Float()})

marshal({'field': {'min': '12.1', 'max': '12.2'}}, model)

Expected Behavior

Given the example code I would expect to receive a MarshallingError with a useful error message directing me to where the problem is.

Actual Behavior

I receive a TypeError only telling me the underlying error with no context.

Environment

  • Python version: 3.8
  • Flask version: 1.1.1
  • Flask-RESTX version: 0.1.1

Additional Context

I have a PR incoming for this. I am opening this issue as that is what the CONTRIBUTING guidelines suggest.

@robyoung robyoung added the bug Something isn't working label Mar 9, 2020
robyoung added a commit to robyoung/flask-restx that referenced this issue Mar 9, 2020
When marshalling receiving a `MarshallingError` is much more useful than
receiving the underlying exception directly as the `MarshallingError`
has context about where it happened and it means all marshalling issues
can be handled in one place.

This change also catches `TypeError`s from the int and float formatters
so that they are correctly turned into `MarshallingError`s.
robyoung added a commit to robyoung/flask-restx that referenced this issue May 16, 2020
When marshalling receiving a `MarshallingError` is much more useful than
receiving the underlying exception directly as the `MarshallingError`
has context about where it happened and it means all marshalling issues
can be handled in one place.

This change also catches `TypeError`s from the int and float formatters
so that they are correctly turned into `MarshallingError`s.
robyoung added a commit to robyoung/flask-restx that referenced this issue May 16, 2020
When marshalling receiving a `MarshallingError` is much more useful than
receiving the underlying exception directly as the `MarshallingError`
has context about where it happened and it means all marshalling issues
can be handled in one place.

This change also catches `TypeError`s from the int and float formatters
so that they are correctly turned into `MarshallingError`s.
j5awry added a commit that referenced this issue May 29, 2020
Fix Issue #75: Catch TypeError in marshalling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant