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

fix(multipart): don't share MultipartParseOptions._DEFAULT_HANDLERS #2322

Merged
merged 4 commits into from
Sep 6, 2024

Conversation

myusko
Copy link
Contributor

@myusko myusko commented Sep 5, 2024

Summary of Changes

Fix a problem, when MultipartParseOptions._DEFAULT_HANDLERS was shared between different instances

Related Issues

Fixes #2293.

Pull Request Checklist

  • Applied changes to both WSGI and ASGI code paths and interfaces (where applicable).
  • Added tests for changed code.
  • Prefixed code comments with GitHub nick and an appropriate prefix.
  • Coding style is consistent with the rest of the framework.
  • [] Updated documentation for changed code.
    • Added docstrings for any new classes, functions, or modules.
    • Updated docstrings for any modifications to existing code.
    • Updated both WSGI and ASGI docs (where applicable).
    • Added references to new classes, functions, or modules to the relevant RST file under docs/.
    • Updated all relevant supporting documentation files under docs/.
    • A copyright notice is included at the top of any new modules (using your own name or the name of your organization).
    • Changed/added classes/methods/functions have appropriate versionadded, versionchanged, or deprecated directives.
  • Changes (and possible deprecations) have towncrier news fragments under docs/_newsfragments/, with the file name format {issue_number}.{fragment_type}.rst. (Run towncrier --draft to ensure it renders correctly.)

@myusko myusko marked this pull request as draft September 5, 2024 12:43
@myusko myusko force-pushed the myusko-fix-multipart-default-headers branch from 206eed7 to bd3cfbb Compare September 5, 2024 12:45
Copy link

codecov bot commented Sep 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (1f914c5) to head (16c8d5b).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##            master     #2322   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           63        63           
  Lines         7499      7502    +3     
  Branches      1275      1275           
=========================================
+ Hits          7499      7502    +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

Thanks for this fix! 👍

Your initial version was not wrong per se, but it was not functioning correctly since the default UserDict.copy() doesn't properly set up Handlers internals. So I took the liberty of implementing a proper Handlers.copy() method, now it seems to pass.

Now, only a Towncrier newsfragment is remaining before we can move this off Draft (barring one non-critical nitpick in the tests).

tests/test_media_multipart.py Outdated Show resolved Hide resolved
CaselIT
CaselIT previously approved these changes Sep 6, 2024
Copy link
Member

@vytas7 vytas7 left a comment

Choose a reason for hiding this comment

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

I have now added the missing newsfragment.

@vytas7 vytas7 requested a review from CaselIT September 6, 2024 07:30
@vytas7 vytas7 marked this pull request as ready for review September 6, 2024 07:30
@vytas7 vytas7 merged commit cae50da into falconry:master Sep 6, 2024
37 checks passed
@myusko myusko deleted the myusko-fix-multipart-default-headers branch September 6, 2024 12:35
vytas7 added a commit that referenced this pull request Sep 27, 2024
* feat (status_codes) update HTTP status code constants wrt RFC 9110
refactor(response): replace falcon.HTTPPayloadTooLarge with falcon.HTTPContentTooLarge

Replace the usage of falcon.HTTPPayloadTooLarge with falcon.HTTPContentTooLarge in the codebase. This change aligns with the recent renaming of the class in the Falcon library. The new class name better reflects the purpose of the error, which is to indicate that the content of the request is too large for the server to process.

Closes #2322

* docs(_newsfragments) documented class name change from HTTPPayloadTooLarge to HTTPContentTooLarge

* fix(status_codes): bring back removed constant for compatibility, fix ruff

* chore: misc touchups

* refactor: add a compat alias HTTPPayloadTooLarge ==> HTTPContentTooLarge

* docs: tweaks newsfragment for HTTP status code updates

---------

Co-authored-by: Vytautas Liuolia <vytautas.liuolia@gmail.com>
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.

Unintended sharing of MultipartParseOptions._DEFAULT_HANDLERS between instances
3 participants