Skip to content

Conversation

@bazel-io
Copy link
Member

@bazel-io bazel-io commented Jan 5, 2026

This reverts commit 65fe463.

Breaks repo rules that hit a download cache entry and subsequently attempt to overwrite the file (e.g. http_archive's handling of remote module files).

Keeps the added test as it doesn't depend on the change.

Work towards #28031

Closes #28148.

PiperOrigin-RevId: 852373210
Change-Id: I9e5e9ae87696068fbcb41cfd4dc77c36fea8248b

Commit d5dba3f

This reverts commit 65fe463.

Breaks repo rules that hit a download cache entry and subsequently attempt to overwrite the file (e.g. http_archive's handling of remote module files).

Keeps the added test as it doesn't depend on the change.

Work towards bazelbuild#28031

Closes bazelbuild#28148.

PiperOrigin-RevId: 852373210
Change-Id: I9e5e9ae87696068fbcb41cfd4dc77c36fea8248b
@bazel-io bazel-io requested a review from a team as a code owner January 5, 2026 19:04
@bazel-io bazel-io added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. awaiting-review PR is awaiting review from an assigned reviewer labels Jan 5, 2026
@bazel-io bazel-io requested a review from meteorcloudy January 5, 2026 19:04
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request partially reverts a previous change, removing the read-only attribute from download cache entries. This is intended to fix a regression where repository rules that need to modify cached files were failing with permission errors.

While this change unblocks those rules, it re-introduces the risk of cache corruption if a hardlinked file is modified by a user. The build system will detect this corruption via checksum validation, but this will result in a build failure requiring manual intervention (deleting the corrupted cache entry). This is a significant trade-off for cache reliability.

For a more robust long-term solution, consider modifying the affected repository rules to request a copy of the file instead of a hardlink when modification is intended. This can be achieved by passing mayHardlink=false to DownloadCache.get().

I am having trouble creating individual review comments. Click here to see my feedback.

src/main/java/com/google/devtools/build/lib/bazel/repository/cache/DownloadCache.java (249-250)

high

Removing this read-only protection re-introduces the risk of cache corruption when hardlinked files are modified. While this is being done to fix a regression, it's a significant trade-off that impacts cache reliability.

The existing checksum validation on cache reads will prevent silent corruption, but it will cause build failures that require users to manually clean their cache directories. This can lead to a frustrating user experience.

As a long-term solution, it would be better to update the repository rules that modify these files to request copies instead of hardlinks (by passing mayHardlink=false to DownloadCache.get()). This would prevent both the permission errors this PR is fixing and the cache corruption issue.

@iancha1992 iancha1992 enabled auto-merge January 5, 2026 20:03
@iancha1992 iancha1992 added this pull request to the merge queue Jan 6, 2026
Merged via the queue into bazelbuild:release-9.0.0 with commit 1bd671d Jan 6, 2026
46 checks passed
@github-actions github-actions bot removed the awaiting-review PR is awaiting review from an assigned reviewer label Jan 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants