Skip to content

[PR #10880/3c9d7abf backport][3.11] Add invalid content type test docs #10885

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

Conversation

patchback[bot]
Copy link
Contributor

@patchback patchback bot commented May 19, 2025

This is a backport of PR #10880 as merged into master (3c9d7ab).

What do these changes do?

This PR adds test coverage for invalid content type handling and documents the expected behavior. The changes include:

  • A test that verifies when an invalid content type (e.g., "jpeg" without "image/") is provided to web.Response, the content_type property correctly defaults to text/plain as per RFC 2045
  • Documentation clarifying that invalid Content-Type headers fall back to text/plain by default

Are there changes in behavior for the user?

No breaking changes. This PR only adds test coverage and documentation for existing behavior. Users will not experience any functional changes:

  • Invalid content types continue to be handled the same way as before
  • The content_type property still defaults to text/plain for invalid values

Is it a substantial burden for the maintainers to support this?

No, this is a minimal maintenance burden. The changes are:

  • Test-only additions: The test is straightforward and tests existing, stable behavior
  • Documentation clarification: Adds a simple note explaining RFC-compliant fallback behavior

The test and documentation help prevent future regressions and improve developer understanding, which actually reduces maintenance burden by making the codebase more self-documenting.

Related issue number

Fixes #9522

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)
    • if you don't have an issue number, change it to the pull request
      number after creating the PR
      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:
      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.
      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

Co-authored-by: J. Nick Koston <[email protected]>
Co-authored-by: Sam Bull <[email protected]>
(cherry picked from commit 3c9d7ab)
@patchback patchback bot requested review from webknjaz and asvetlov as code owners May 19, 2025 16:38
@patchback patchback bot mentioned this pull request May 19, 2025
5 tasks
Copy link

codecov bot commented May 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.09%. Comparing base (3ebbb02) to head (17501ab).
Report is 1 commits behind head on 3.11.

✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             3.11   #10885      +/-   ##
==========================================
- Coverage   98.09%   98.09%   -0.01%     
==========================================
  Files         126      126              
  Lines       37725    37729       +4     
  Branches     4562     4562              
==========================================
+ Hits        37008    37011       +3     
  Misses        542      542              
- Partials      175      176       +1     
Flag Coverage Δ
CI-GHA 97.98% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.68% <100.00%> (+<0.01%) ⬆️
OS-Windows 94.72% <100.00%> (+<0.01%) ⬆️
OS-macOS 96.82% <100.00%> (+<0.01%) ⬆️
Py-3.10.11 96.69% <100.00%> (+<0.01%) ⬆️
Py-3.10.17 97.24% <100.00%> (+<0.01%) ⬆️
Py-3.11.12 97.26% <100.00%> (+<0.01%) ⬆️
Py-3.11.9 96.76% <100.00%> (-0.01%) ⬇️
Py-3.12.10 97.76% <100.00%> (+<0.01%) ⬆️
Py-3.13.3 97.70% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 96.59% <100.00%> (+<0.01%) ⬆️
Py-3.9.22 97.14% <100.00%> (+0.03%) ⬆️
Py-pypy7.3.16 96.68% <100.00%> (+<0.01%) ⬆️
VM-macos 96.82% <100.00%> (+<0.01%) ⬆️
VM-ubuntu 97.68% <100.00%> (+<0.01%) ⬆️
VM-windows 94.72% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copy link

codspeed-hq bot commented May 19, 2025

CodSpeed Performance Report

Merging #10885 will not alter performance

Comparing patchback/backports/3.11/3c9d7abfed11a8f9d95761b8a8188816d70635c5/pr-10880 (17501ab) with 3.11 (3ebbb02)

Summary

✅ 56 untouched benchmarks

@bdraco bdraco merged commit 46b9d15 into 3.11 May 19, 2025
36 checks passed
@bdraco bdraco deleted the patchback/backports/3.11/3c9d7abfed11a8f9d95761b8a8188816d70635c5/pr-10880 branch May 19, 2025 18:16
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