Skip to content

fix(downloads): set 0o644 permissions on downloaded files - #1282

Merged
mergify[bot] merged 1 commit into
python-wheel-build:mainfrom
smoparth:fix/1281-download-file-permissions
Jul 30, 2026
Merged

fix(downloads): set 0o644 permissions on downloaded files#1282
mergify[bot] merged 1 commit into
python-wheel-build:mainfrom
smoparth:fix/1281-download-file-permissions

Conversation

@smoparth

Copy link
Copy Markdown
Contributor

NamedTemporaryFile creates files with mode 0o600, making them unreadable by external wheel servers (e.g. nginx) that run as a different user. This caused 403 Forbidden errors when uv pip install tried to fetch wheels from the local package index.

Use os.fchmod before close+rename to widen permissions to 0o644, preserving the atomicity and thread-safety benefits of NamedTemporaryFile.

Closes: #1281

Pull Request Description

What

Why

@smoparth
smoparth requested a review from a team as a code owner July 30, 2026 12:43
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@smoparth, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 45 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f5c7c68-90aa-4f0c-8ad4-8961228c9068

📥 Commits

Reviewing files that changed from the base of the PR and between e16b86b and efef444.

📒 Files selected for processing (2)
  • src/fromager/downloads.py
  • tests/test_downloads.py
📝 Walkthrough

Walkthrough

The download helper now imports stat and changes temporary file permissions to include group-read and other-read access before closing and atomically renaming the file. A new test mocks a download and verifies those permission bits on the resulting file.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The change satisfies #1281 by making downloaded wheels readable while preserving atomic rename behavior.
Out of Scope Changes check ✅ Passed The PR stays focused on download permissions and the corresponding test, with no obvious unrelated changes.
Title check ✅ Passed The title clearly summarizes the main change: widening downloaded file permissions to 0o644.
Description check ✅ Passed The description matches the patch and explains the permission fix and its motivation.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify mergify Bot added the ci label Jul 30, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/test_downloads.py`:
- Around line 77-85: Update test_download_url_world_readable to assert that mode
equals exactly 0o644, replacing the separate group-read and other-read bit
checks while preserving the existing download setup.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 64fcbe23-f5a5-43e3-87ea-935db549a8fe

📥 Commits

Reviewing files that changed from the base of the PR and between ebbd889 and e16b86b.

📒 Files selected for processing (2)
  • src/fromager/downloads.py
  • tests/test_downloads.py

Comment thread tests/test_downloads.py Outdated
`NamedTemporaryFile` creates files with mode 0o600, making them
unreadable by external wheel servers (e.g. nginx) that run as a
different user. This caused 403 Forbidden errors when `uv pip install`
tried to fetch wheels from the local package index.

Use `os.fchmod` before close+rename to widen permissions to 0o644,
preserving the atomicity and thread-safety benefits of
`NamedTemporaryFile`.

Closes: python-wheel-build#1281
Co-Authored-By: Claude <claude@anthropic.com>
Signed-off-by: Shanmukh Pawan <smoparth@redhat.com>
@smoparth
smoparth force-pushed the fix/1281-download-file-permissions branch from e16b86b to efef444 Compare July 30, 2026 12:57

@rd4398 rd4398 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This looks good! Thanks

@mergify
mergify Bot merged commit d3e21a6 into python-wheel-build:main Jul 30, 2026
39 checks passed
@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(downloads): NamedTemporaryFile creates wheels with 0o600 permissions, breaking external wheel servers

2 participants