Skip to content

Handle missing MIME type in MediaTypeFinder #371

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

Merged
merged 1 commit into from
Aug 16, 2021

Conversation

jparise
Copy link
Contributor

@jparise jparise commented Aug 13, 2021

It's possible for a response not to have a MIME type (mimetype=None).
Previously, this would result in an exception from within fnmatch():

TypeError: expected str, bytes or os.PathLike object, not NoneType

This change guards against that condition and raises MediaTypeNotFound
instead. Tests have also been added for this module.

@jparise jparise changed the title Handle missing MIME types in MediaTypeFinder Handle missing MIME type in MediaTypeFinder Aug 13, 2021
@codecov
Copy link

codecov bot commented Aug 13, 2021

Codecov Report

Merging #371 (d064386) into master (4ce032c) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #371      +/-   ##
==========================================
+ Coverage   73.23%   73.24%   +0.01%     
==========================================
  Files          80       80              
  Lines        2391     2392       +1     
==========================================
+ Hits         1751     1752       +1     
  Misses        640      640              
Impacted Files Coverage Δ
openapi_core/templating/media_types/finders.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ce032c...d064386. Read the comment docs.

It's possible for a response not to have a MIME type (mimetype=None).
Previously, this would result in an exception from within fnmatch():

  TypeError: expected str, bytes or os.PathLike object, not NoneType

This change guards against that condition and raises MediaTypeNotFound
instead. Tests have also been added for this module.
@jparise jparise force-pushed the media_type_finder branch from 7703591 to d064386 Compare August 13, 2021 20:03
Copy link
Collaborator

@p1c2u p1c2u left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@p1c2u p1c2u merged commit b728167 into python-openapi:master Aug 16, 2021
@jparise jparise deleted the media_type_finder branch August 16, 2021 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants