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 response to circular symlinks with Python v3.13 #8642

Merged
merged 3 commits into from
Aug 8, 2024

Conversation

steverep
Copy link
Member

@steverep steverep commented Aug 8, 2024

What do these changes do?

In 3.13, pathlib has changed Path.resolve() from always raising RuntimeError on circular symlinks to raising OSError only when strict=True. To adapt, we either need to resolve strictly, or just catch the error later in FileResponse. I chose the latter because resolving strictly creates a mess in order to keep the ability to store only compressed files.

I also think just catching OSError instead of FileNotFoundError in FileResponse is better overall since it may also catch just random file system glitches that would otherwise end up causing a server disconnect.

Full disclosure: I did not test this on the 3.13 RC but will ask the issue author to do so.

Are there changes in behavior for the user?

No

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

No

Related issue number

Fixes #8565

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.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Aug 8, 2024
@steverep steverep added backport-3.10 backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot labels Aug 8, 2024
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.93%. Comparing base (13ef3c1) to head (93203f8).
Report is 2769 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8642      +/-   ##
==========================================
+ Coverage   97.66%   97.93%   +0.26%     
==========================================
  Files         108      107       -1     
  Lines       33852    33669     -183     
  Branches     4027     3952      -75     
==========================================
- Hits        33063    32974      -89     
+ Misses        588      515      -73     
+ Partials      201      180      -21     
Flag Coverage Δ
CI-GHA 97.85% <100.00%> (+0.27%) ⬆️
OS-Linux 97.51% <100.00%> (+0.25%) ⬆️
OS-Windows 95.87% <100.00%> (+1.11%) ⬆️
OS-macOS 97.17% <100.00%> (+0.25%) ⬆️
Py-3.10.11 97.32% <100.00%> (+0.29%) ⬆️
Py-3.10.14 97.26% <100.00%> (+0.27%) ⬆️
Py-3.11.9 97.49% <100.00%> (+0.27%) ⬆️
Py-3.12.4 97.62% <100.00%> (+0.28%) ⬆️
Py-3.8.10 95.64% <100.00%> (+1.14%) ⬆️
Py-3.8.18 97.16% <100.00%> (+0.28%) ⬆️
Py-3.9.13 97.31% <100.00%> (+0.28%) ⬆️
Py-3.9.19 97.25% <100.00%> (+0.26%) ⬆️
Py-pypy7.3.16 96.84% <100.00%> (+0.27%) ⬆️
VM-macos 97.17% <100.00%> (+0.25%) ⬆️
VM-ubuntu 97.51% <100.00%> (+0.25%) ⬆️
VM-windows 95.87% <100.00%> (+1.11%) ⬆️

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.

@mgorny
Copy link
Contributor

mgorny commented Aug 8, 2024

Thanks. I can confirm that this fixes the issue for me.

@bdraco bdraco added this to the 3.10.2 milestone Aug 8, 2024
@bdraco bdraco changed the title Fix response to circular symlinks on v3.13 Fix response to circular symlinks with Python v3.13 Aug 8, 2024
aiohttp/web_urldispatcher.py Outdated Show resolved Hide resolved
@bdraco
Copy link
Member

bdraco commented Aug 8, 2024

Thanks @steverep

@bdraco bdraco merged commit e494277 into aio-libs:master Aug 8, 2024
37 of 38 checks passed
Copy link
Contributor

patchback bot commented Aug 8, 2024

Backport to 3.10: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.10/e494277110e40fb5c1cc65a1558dfea7d8ae7ca8/pr-8642

Backported as #8648

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Aug 8, 2024
Co-authored-by: J. Nick Koston <nick@koston.org>
(cherry picked from commit e494277)
Copy link
Contributor

patchback bot commented Aug 8, 2024

Backport to 3.11: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.11/e494277110e40fb5c1cc65a1558dfea7d8ae7ca8/pr-8642

Backported as #8649

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Aug 8, 2024
Co-authored-by: J. Nick Koston <nick@koston.org>
(cherry picked from commit e494277)
bdraco pushed a commit that referenced this pull request Aug 8, 2024
…with Python v3.13 (#8648)

Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
bdraco pushed a commit that referenced this pull request Aug 8, 2024
…with Python v3.13 (#8649)

Co-authored-by: Steve Repsher <steverep@users.noreply.github.com>
@steverep steverep deleted the fix-circular-symlinks-py313 branch August 8, 2024 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.11 Trigger automatic backporting to the 3.11 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Python 3.13: symlink loop handling broken? (tests/test_web_urldispatcher.py::test_access_symlink_loop failure)
3 participants