{"record":{"id":"91bc24bbde7ae762","repo":"bazelbuild/bazel","slug":"setvalue-operation-from-invocation-policy-for-s-d","errorCode":null,"errorMessage":"SetValue operation from invocation policy for %s does not have a value","messagePattern":"SetValue operation from invocation policy for (.+?) does not have a value","errorType":"exception","errorClass":"OptionsParsingException","httpStatus":null,"severity":"error","filePath":"src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java","lineNumber":556,"sourceCode":"        return null;\n    }\n    return subflagAsPolicy;\n  }\n\n  private static void applySetValueOperation(\n      OptionsParser parser,\n      FlagPolicyWithContext flagPolicy,\n      OptionValueDescription valueDescription,\n      Level loglevel,\n      Object conversionContext,\n      ImmutableList.Builder<OptionAndRawValue> invocationPolicyFlagListBuilder)\n      throws OptionsParsingException {\n    SetValue setValue = flagPolicy.policy.getSetValue();\n    OptionDefinition optionDefinition = flagPolicy.description.getOptionDefinition();\n\n    // SetValue.flag_value must have at least 1 value.\n    if (setValue.getFlagValueCount() == 0) {\n      throw new OptionsParsingException(\n          String.format(\n              \"SetValue operation from invocation policy for %s does not have a value\",\n              optionDefinition));\n    }\n\n    // Flag must allow multiple values if multiple values are specified by the policy.\n    if (setValue.getFlagValueCount() > 1\n        && !flagPolicy.description.getOptionDefinition().allowsMultiple()) {\n      throw new OptionsParsingException(\n          String.format(\n              \"SetValue operation from invocation policy sets multiple values for %s which \"\n                  + \"does not allow multiple values\",\n              optionDefinition));\n    }\n\n    switch (setValue.getBehavior()) {\n      case UNDEFINED:\n        throw throwUndefinedBehaviorException(flagPolicy.policy);","sourceCodeStart":538,"sourceCodeEnd":574,"githubUrl":"https://github.com/bazelbuild/bazel/blob/e6e199d0601a244511b4cf18c8b2828aa73db1fd/src/main/java/com/google/devtools/common/options/InvocationPolicyEnforcer.java#L538-L574","documentation":"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.","triggerScenarios":"Policy entry {\"flagName\":\"...\",\"setValue\":{}} or {\"flagName\":\"...\",\"setValue\":{\"behavior\":\"ALLOW_OVERRIDES\"}} — setValue present but flagValue list empty/omitted.","commonSituations":"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).","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."],"exampleFix":"// before\n{\"flagName\":\"compilation_mode\",\"setValue\":{\"behavior\":\"ALLOW_OVERRIDES\"}}\n\n// after\n{\"flagName\":\"compilation_mode\",\"setValue\":{\"flagValue\":[\"opt\"],\"behavior\":\"ALLOW_OVERRIDES\"}}","handlingStrategy":"validation","validationCode":"for (FlagPolicy fp : policy.getFlagPoliciesList()) {\n  if (fp.hasSetValue() && fp.getSetValue().getFlagValueCount() == 0) {\n    throw new IllegalStateException(\"setValue for '\" + fp.getFlagName() + \"' has no flag_value\");\n  }\n}","typeGuard":null,"tryCatchPattern":"Catch OptionsParsingException; add at least one flagValue or switch the entry to use_default if 'reset' was the intent.","preventionTips":["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"],"tags":["invocation-policy","set-value","policy","bazel"],"backgroundTag":null,"analyzedSha":"e6e199d0601a244511b4cf18c8b2828aa73db1fd","analyzedAt":"2026-08-14T10:24:27.848Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}