phacility/phabricator · warning · Exception
Value "%s" is not valid for setting "%s": valid values are %
Error message
Value "%s" is not valid for setting "%s": valid values are %s.
What it means
Base class for settings rendered as grouped <select> dropdowns (PhabricatorSelectEditField with option groups). Its final validateTransactionValue() accepts the empty string (unset) but throws for any value not present as a key in getSelectOptionMap(). This stops stale, removed, or forged option keys from being persisted through settings transactions.
Source
Thrown at src/applications/settings/setting/PhabricatorOptionGroupSetting.php:54
$flat_options = array();
foreach ($options as $group) {
$flat_options[$group['label']] = $group['options'];
}
return $this->newEditField($object, new PhabricatorSelectEditField())
->setOptions($flat_options);
}
final public function validateTransactionValue($value) {
if (!strlen($value)) {
return;
}
$map = $this->getSelectOptionMap();
if (!isset($map[$value])) {
throw new Exception(
pht(
'Value "%s" is not valid for setting "%s": valid values are %s.',
$value,
$this->getSettingName(),
implode(', ', array_keys($map))));
}
return;
}
public function getTransactionNewValue($value) {
if (!strlen($value)) {
return null;
}
return (string)$value;
}
View on GitHub (pinned to 5720a38cfe)
Solutions
- Reload the settings form and pick from the currently offered options
- If you maintain the setting class, either re-add the option or write a migration for stored values
- For API writes, enumerate valid keys from getSelectOptionGroups()/getSelectOptionMap() at runtime instead of hardcoding
Defensive patterns
Strategy: type-guard
Type guard
function isValidOptionGroupSettingValue(PhabricatorOptionGroupSetting $setting, $value) {
$value = phutil_string_cast($value);
if (!strlen($value)) { return true; } // empty = unset, allowed
return isset($setting->getSelectOptionMap()[$value]);
} Try / catch
try {
// write the setting
} catch (Exception $ex) {
// value not in the option map: refetch current options and resubmit
} Prevention
- Source enum values from the live option map, never from hardcoded copies
- Re-render settings forms after upgrades before submitting
- When renaming options in custom settings, keep legacy keys or migrate stored values
When it happens
Trigger: Posting a settings transaction whose value is a key absent from the option map: a value removed in a newer release, a hand-crafted Conduit/settings request with an arbitrary string, or a cached form posting an old value after the option set changed.
Common situations: Downgrades or fork divergence where an option was removed; API clients hardcoding option keys; browser-cached settings forms submitting pre-upgrade values.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Value "%s" is not valid for setting "%s": valid values are %
- Unknown repository operation target type "%s" (in target "%s
- Unknown condition "%s"!
- Timezone "%s" is not a valid timezone identifier.
- Service "%s" is unrecognized, restricted, or you do not have
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/b1fa7e47429a9f94.
Report an issue: GitHub.