bazelbuild/bazel · error · OptionsParsingException
SetValue operation from invocation policy sets multiple valu
Error message
SetValue operation from invocation policy sets multiple values for %s which does not allow multiple values
What it means
Thrown by applySetValueOperation when a policy's set_value supplies more than one flag_value but the target option does not allow multiple values (not a repeatable/multiple-use flag). Single-valued options cannot accept a list, so the policy is rejected before enforcement.
Source
Thrown at src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java:565
Level loglevel,
Object conversionContext,
ImmutableList.Builder<OptionAndRawValue> invocationPolicyFlagListBuilder)
throws OptionsParsingException {
SetValue setValue = flagPolicy.policy.getSetValue();
OptionDefinition optionDefinition = flagPolicy.description.getOptionDefinition();
// SetValue.flag_value must have at least 1 value.
if (setValue.getFlagValueCount() == 0) {
throw new OptionsParsingException(
String.format(
"SetValue operation from invocation policy for %s does not have a value",
optionDefinition));
}
// Flag must allow multiple values if multiple values are specified by the policy.
if (setValue.getFlagValueCount() > 1
&& !flagPolicy.description.getOptionDefinition().allowsMultiple()) {
throw new OptionsParsingException(
String.format(
"SetValue operation from invocation policy sets multiple values for %s which "
+ "does not allow multiple values",
optionDefinition));
}
switch (setValue.getBehavior()) {
case UNDEFINED:
throw throwUndefinedBehaviorException(flagPolicy.policy);
case ALLOW_OVERRIDES:
if (valueDescription != null) {
// The user set the value for the flag but the flag policy is overridable, so keep the
// user's value.
logger.at(loglevel).log(
"Keeping value '%s' from source '%s' for %s because the invocation policy specifying "
+ "the value(s) '%s' is overridable",
valueDescription.getValue(),
valueDescription.getSourceString(),View on GitHub (pinned to e6e199d060)
Solutions
- Reduce flagValue to exactly one entry for single-valued flags.
- If multiple values are genuinely needed, target a repeatable flag (one whose help shows it may be used multiple times).
- Check the option definition: bazel help lists whether a flag is repeatable (shows 'multiple uses' semantics).
Example fix
// before
{"flagName":"compilation_mode","setValue":{"flagValue":["opt","dbg"],"behavior":"ALLOW_OVERRIDES"}}
// after
{"flagName":"compilation_mode","setValue":{"flagValue":["opt"],"behavior":"ALLOW_OVERRIDES"}} Defensive patterns
Strategy: validation
Validate before calling
// Multiple values only for repeatable flags
for (FlagPolicy fp : policy.getFlagPoliciesList()) {
if (fp.hasSetValue() && fp.getSetValue().getFlagValueCount() > 1) {
OptionDefinition def = optionIndex.get(fp.getFlagName());
if (def != null && !def.allowsMultiple()) {
throw new IllegalStateException(fp.getFlagName() + " is single-valued; supply one flag_value");
}
}
} Try / catch
Catch OptionsParsingException; the message names the single-valued option — trim flagValue to one entry.
Prevention
- Check flag repeatability in bazel help before writing multi-value policies
- Only list flags (used multiple times) may take multiple flag_value entries
- Keep a curated list of which org flags are repeatable
When it happens
Trigger: Policy like {"flagName":"compilation_mode","setValue":{"flagValue":["opt","dbg"],...}} — compilation_mode takes exactly one value. Repeatable flags (allowsMultiple(), e.g. --define-style list flags) are the only ones that may receive multiple values.
Common situations: Policy authors giving multiple 'fallback' values to a single-value flag, copy-pasting a repeatable-flag policy pattern onto a scalar flag, misunderstanding that flagValue is a list only for repeated flags.
Related errors
- SetValue operation from invocation policy for has an undefin
- SetValue operation from invocation policy for %s does not ha
- Flag value '%s' for %s is not allowed by invocation policy.
- Flag policy for flag '%s' does not have an operation
- Invocation policy is applied after --config expansion, chang
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/d3cba939e0563bac.
Report an issue: GitHub.