bazelbuild/bazel · error · OptionsParsingException
SetValue operation from invocation policy for %s does not ha
Error message
SetValue operation from invocation policy for %s does not have a value
What it means
Thrown by applySetValueOperation when a policy's set_value operation declares zero flag_value entries. SetValue requires at least one value to enforce; an empty setValue message is structurally invalid and rejected before any behavior switch runs.
Source
Thrown at src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java:556
return null;
}
return subflagAsPolicy;
}
private static void applySetValueOperation(
OptionsParser parser,
FlagPolicyWithContext flagPolicy,
OptionValueDescription valueDescription,
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);View on GitHub (pinned to e6e199d060)
Solutions
- Add at least one flagValue: {"setValue":{"flagValue":["opt"],"behavior":"..."}}.
- If the intent is to force the flag's default, use the use_default operation instead of an empty set_value.
- Lint policies: assert setValue.flagValue.length >= 1 wherever setValue appears.
Example fix
// before
{"flagName":"compilation_mode","setValue":{"behavior":"ALLOW_OVERRIDES"}}
// after
{"flagName":"compilation_mode","setValue":{"flagValue":["opt"],"behavior":"ALLOW_OVERRIDES"}} Defensive patterns
Strategy: validation
Validate before calling
for (FlagPolicy fp : policy.getFlagPoliciesList()) {
if (fp.hasSetValue() && fp.getSetValue().getFlagValueCount() == 0) {
throw new IllegalStateException("setValue for '" + fp.getFlagName() + "' has no flag_value");
}
} Try / catch
Catch OptionsParsingException; add at least one flagValue or switch the entry to use_default if 'reset' was the intent.
Prevention
- Use use_default for 'force default', never an empty set_value
- Fill template value slots with validation that they are non-empty
- Lint flagValueCount >= 1 for all setValue entries
When it happens
Trigger: Policy entry {"flagName":"...","setValue":{}} or {"flagName":"...","setValue":{"behavior":"ALLOW_OVERRIDES"}} — setValue present but flagValue list empty/omitted.
Common situations: Policies generated from templates where the value slot is filled from an empty variable, docs examples with a placeholder value removed, intent confusion: author wanted 'reset to default' (which is use_default, not empty set_value).
Related errors
- Invocation policy is applied after --config expansion, chang
- Allow_Values on expansion flags like %s is not allowed.
- Disallow_Values on expansion flags like %s is not allowed.
- SetValue operation from invocation policy for has an undefin
- SetValue operation from invocation policy sets multiple valu
AI-assisted analysis of bazelbuild/bazel@e6e199d060 (2026-08-14).
Data as JSON: /api/errors/91bc24bbde7ae762.
Report an issue: GitHub.