[9.3.0] Don't crash on a constraint value repeated via an alias (https://github.com/bazelbuild/bazel/pull/30488) - #30534
Open
bazel-io wants to merge 1 commit into
Open
Conversation
…0488) ### Description `ConstraintCollection.validateConstraints` explicitly permits multiple instances of the *same* constraint value and only rejects different values for the same constraint setting. `ConstraintCollection.Builder#build` then collected the values into an `ImmutableMap` keyed by constraint setting without a merge function, so any repetition crashed Bazel with Multiple entries with same key: ConstraintSettingInfo(...)=ConstraintValueInfo(...) This is easy to hit accidentally when a constraint value is referenced both directly and through an `alias`, e.g. `@bazel_tools//tools/cpp:mingw` and `@rules_cc//cc/private/toolchain:mingw` in a `toolchain`'s `target_compatible_with`. Since validation guarantees that all values for a given setting are equal at this point, keep the first one. ### Motivation Fixes bazel-contrib/rules_go#4665 ### Build API Changes No ### Checklist - [x] I have added tests for the new use cases (if any). - [x] I have updated the documentation (if applicable). ### Release Notes RELNOTES: None Closes bazelbuild#30488. PiperOrigin-RevId: 956129840 Change-Id: Ic5771803e104d1e3550527a11e6403dcb3cfe535
iancha1992
enabled auto-merge
July 30, 2026 00:36
katre
approved these changes
Jul 30, 2026
gregestren
approved these changes
Jul 30, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to no response for status checks
Jul 30, 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.
Description
ConstraintCollection.validateConstraintsexplicitly permits multiple instances of the same constraint value and only rejects different values for the same constraint setting.ConstraintCollection.Builder#buildthen collected the values into anImmutableMapkeyed by constraint setting without a merge function, so any repetition crashed Bazel withThis is easy to hit accidentally when a constraint value is referenced both directly and through an
alias, e.g.@bazel_tools//tools/cpp:mingwand@rules_cc//cc/private/toolchain:mingwin atoolchain'starget_compatible_with.Since validation guarantees that all values for a given setting are equal at this point, keep the first one.
Motivation
Fixes bazel-contrib/rules_go#4665
Build API Changes
No
Checklist
Release Notes
RELNOTES: None
Closes #30488.
PiperOrigin-RevId: 956129840
Change-Id: Ic5771803e104d1e3550527a11e6403dcb3cfe535
Commit afd06ce