{"record":{"id":"69eeecc6e7461025","repo":"phacility/phabricator","slug":"almanac-service-device-property-network-and-nam","errorCode":null,"errorMessage":"Almanac service, device, property, network and namespace names must be at least 3 characters long.","messagePattern":"Almanac service, device, property, network and namespace names must be at least 3 characters long\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/almanac/util/AlmanacNames.php","lineNumber":7,"sourceCode":"<?php\n\nfinal class AlmanacNames extends Phobject {\n\n  public static function validateName($name) {\n    if (strlen($name) < 3) {\n      throw new Exception(\n        pht(\n          'Almanac service, device, property, network and namespace names '.\n          'must be at least 3 characters long.'));\n    }\n\n    if (strlen($name) > 100) {\n      throw new Exception(\n        pht(\n          'Almanac service, device, property, network and namespace names '.\n          'may not be more than 100 characters long.'));\n    }\n\n    if (!preg_match('/^[a-z0-9.-]+\\z/', $name)) {\n      throw new Exception(\n        pht(\n          'Almanac service, device, property, network and namespace names '.\n          'may only contain lowercase letters, numbers, hyphens, and '.\n          'periods.'));","sourceCodeStart":1,"sourceCodeEnd":25,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/almanac/util/AlmanacNames.php#L1-L25","documentation":"AlmanacNames::validateName() enforces the shared naming contract for Almanac services, devices, properties, networks and namespaces. The first rule rejects names shorter than 3 characters, because names are used as DNS-like identifiers and single/double-character names are reserved or too collision-prone.","triggerScenarios":"Creating or renaming any named Almanac object with strlen($name) < 3, e.g. 'db', 'w1', or an empty string, through the UI, Conduit API, or CLI.","commonSituations":"Scripted provisioning trying to create short host aliases; fat-fingered empty form submit; migrating inventory that used 2-letter rack codes.","solutions":["Choose a name of at least 3 characters, e.g. 'db1' instead of 'db' or 'w1' -> 'web01'.","If importing existing inventory, transform names during import to satisfy the minimum length.","Check the other rules in AlmanacNames::validateName() at the same time so the retry passes all of them (length <= 100, charset, segment rules)."],"exampleFix":"// before\n$device->setName('db');   // throws: must be at least 3 characters\n\n// after\n$device->setName('db1');  // passes minimum length","handlingStrategy":"validation","validationCode":"function almanacNameMeetsLengthRule($name) {\n  $len = strlen($name);\n  return $len >= 3 && $len <= 100;\n}\n// if (!almanacNameMeetsLengthRule($name)) { /* reject with clear message */ }","typeGuard":"function isValidAlmanacNameLength($name) {\n  return strlen($name) >= 3;\n}","tryCatchPattern":"try {\n  AlmanacNames::validateName($name);\n} catch (Exception $ex) {\n  // Surface which rule failed to the form/API caller so they can fix the input.\n  $errors[] = $ex->getMessage();\n}","preventionTips":["Validate names client-side/API-side with the same 3-character minimum before calling create.","Never provision single- or double-character identifiers; pick a naming convention with room.","Run AlmanacNames::validateName() in a dry-run pass when bulk-importing inventory."],"tags":["almanac","validation","naming","phabricator"],"backgroundTag":"identifier-validation-failed","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}