phacility/phabricator · error · Exception
Almanac service, device, property, network and namespace nam
Error message
Almanac service, device, property, network and namespace names may not contain multiple consecutive hyphens.
What it means
Seventh rule of AlmanacNames::validateName(): the name may not contain '--' (multiple consecutive hyphens). DNS labels disallow consecutive hyphens except in special xn-- forms, and Phabricator rejects them uniformly for all Almanac object names.
Source
Thrown at src/applications/almanac/util/AlmanacNames.php:50
'may not have any segments containing only digits.'));
}
if (preg_match('/\.\./', $name)) {
throw new Exception(
pht(
'Almanac service, device, property, network and namespace names '.
'may not contain multiple consecutive periods.'));
}
if (preg_match('/\\.-|-\\./', $name)) {
throw new Exception(
pht(
'Almanac service, device, property, network and namespace names '.
'may not contain hyphens adjacent to periods.'));
}
if (preg_match('/--/', $name)) {
throw new Exception(
pht(
'Almanac service, device, property, network and namespace names '.
'may not contain multiple consecutive hyphens.'));
}
if (!preg_match('/^[a-z0-9].*[a-z0-9]\z/', $name)) {
throw new Exception(
pht(
'Almanac service, device, property, network and namespace names '.
'must begin and end with a letter or number.'));
}
}
}
View on GitHub (pinned to 5720a38cfe)
Solutions
- Collapse runs when sanitizing: $name = preg_replace('/-+/', '-', $name);
- Fix the literal name: 'web--01' -> 'web-01'.
- Use a single regex replacement of '/[^a-z0-9.-]+/' so whole runs become one hyphen, not several.
Example fix
// before
$name = preg_replace('/[^a-z0-9.-]/', '-', 'web__01'); // 'web--01' -> throws
// after
$name = preg_replace('/[^a-z0-9.-]+/', '-', 'web__01'); // 'web-01' Defensive patterns
Strategy: validation
Validate before calling
if (preg_match('/--/', $name)) {
throw new Exception('Name contains consecutive hyphens.');
}
// Prevent at construction time:
$name = preg_replace('/-+/', '-', $name); Type guard
function hasNoConsecutiveHyphens($name) {
return strpos($name, '--') === false;
} Try / catch
try {
AlmanacNames::validateName($name);
} catch (Exception $ex) {
if (preg_match('/multiple consecutive hyphens/', $ex->getMessage())) {
$name = preg_replace('/-+/', '-', $name); // collapse, re-run all rules
AlmanacNames::validateName($name);
} else {
throw $ex;
}
} Prevention
- Use '+-' quantifiers in slug regexes so runs collapse to a single hyphen.
- Do not join strings with '-' when either side may already end with '-'.
- Round-trip generated names through AlmanacNames::validateName() in tests.
When it happens
Trigger: Submitting names like 'web--01' or 'a--b', most often after a sanitizer replaces a run of bad characters with hyphens (e.g. 'web__01' or 'web / 01' becoming 'web--01').
Common situations: Naive slugification replacing each invalid character individually; joining components with '-' where one side already ends in '-'.
Related errors
- Almanac service, device, property, network and namespace nam
- Almanac service, device, property, network and namespace nam
- Almanac service, device, property, network and namespace nam
- Almanac service, device, network, property and namespace nam
- Almanac service, device, property, network and namespace nam
AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21).
Data as JSON: /api/errors/3890435b11fb46c5.
Report an issue: GitHub.