Repository navigation
fix(hash): skip registry URLs pinned by their own integrity (#544) - #545
Merged
tinder-maxwellelliott merged 3 commits intoOct 23, 2026
Merged
tinder-maxwellelliott merged 3 commits into
tinder-maxwellelliott merged 3 commits into
Conversation
…der#544) A module from a `file://%workspace%/registry` registry has `remote_patches`, `remote_file_urls` and `remote_module_file_urls` that name the checkout's absolute path, so the same commit hashed differently at two paths and every dependent of the module showed up as impacted. Each of these URLs is pinned by its own integrity, so hash the integrity and drop the URL, as pinned `url`/`urls` already are. Applies to target hashes and to the module definition hash extension repositories carry.
Check the attribute name before cloning, cover an unpinned overlay file and MODULE.bazel separately, cover a changed MODULE.bazel integrity, and reword the doc comments, test comments and README paragraph.
tinder-maxwellelliott
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a module comes from a local registry inside the workspace (
--registry=file://%workspace%/registry), Bazel expands%workspace%. The module'sremote_patches,remote_file_urlsandremote_module_file_urlsthen hold absolutefile://URLs that point into the checkout. bazel-diff hashed these attributes verbatim, so the same commit got different hashes at two paths, and diffing those hashes reported every target that depends on the module as impacted.serveinstances at different paths that share a remote cache read each other's hashes and report the same false impacts, because the cache key does not include the path.Fix
bazel-diff already leaves
url/urlsout of a repository's hash whensha256orintegritypins the download. The registry URLs are pinned the same way, each by its own integrity:remote_patchesURL by its value,remote_file_urlsentry by the matchingremote_file_integrityentry,remote_module_file_urlsbyremote_module_file_integrity.The new
without_integrity_pinned_urlsdrops each URL whose integrity is set and keeps the integrity. Patch order is still hashed, and so is any URL without an integrity. The fix doesn't need to know the workspace path, and a registry that moves to a new URL no longer changes the hash either.It applies in two places: the
//external:*target hashes, andrepository_definition_hash, the hash of a module's definition that bazel-diff adds to each of the module's extension repositories.Tests
hash::tests::external_rule_digest_ignores_registry_urls_pinned_by_their_integrity: the same rule under two checkout roots hashes the same. A changed or reordered patch, a changed overlay file orMODULE.bazel, or an unpinned patch, overlay orMODULE.bazelURL still changes the hash.bazel::tests::extension_repos_carry_their_owning_modules_definition:repository_definition_hashignores the checkout path in aremote_patchesURL and still changes when the patch integrity changes.regressions::registry_urls_under_the_workspace_do_not_depend_on_its_path: it adds a registry patch to thesingle_version_override_patchfixture. Two identical copies at different paths now impact nothing (before the fix://:consumer), and a changed registry patch still impacts//:consumer. I regeneratedtools/e2e/rust_e2e_cases.bzl.file://%workspace%registry #544 prints no impacted targets.cargo test --lib,cargo clippy --all-targets -- -D warnings,cargo fmt --check, the regen check, and the Bzlmod, extension-repo and single-version-override e2e cases on Bazel 8.7.0; they pass.external::bzlmod_transitive_deps_cqueryfails on my machine because it has no JDK; this is unrelated to the change.Fixes #544.