{"record":{"id":"89c17bbe940c96b3","repo":"phacility/phabricator","slug":"publisher-key-s-is-not-valid-publisher-keys-mu","errorCode":null,"errorMessage":"Publisher key \"%s\" is not valid: publisher keys must not be more than %s characters long.","messagePattern":"Publisher key \"(.+?)\" is not valid: publisher keys must not be more than (.+?) characters long\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/packages/storage/PhabricatorPackagesPublisher.php","lineNumber":88,"sourceCode":"          'Publisher name \"%s\" is not valid: publisher names must not be '.\n          'more than %s characters long.',\n          $value,\n          new PhutilNumber($max_length)));\n    }\n  }\n\n  public static function assertValidPublisherKey($value) {\n    $length = phutil_utf8_strlen($value);\n    if (!$length) {\n      throw new Exception(\n        pht(\n          'Publisher key \"%s\" is not valid: publisher keys are required.',\n          $value));\n    }\n\n    $max_length = 64;\n    if ($length > $max_length) {\n      throw new Exception(\n        pht(\n          'Publisher key \"%s\" is not valid: publisher keys must not be '.\n          'more than %s characters long.',\n          $value,\n          new PhutilNumber($max_length)));\n    }\n\n    if (!preg_match('/^[a-z]+\\z/', $value)) {\n      throw new Exception(\n        pht(\n          'Publisher key \"%s\" is not valid: publisher keys may only contain '.\n          'lowercase latin letters.',\n          $value));\n    }\n  }\n\n\n/* -(  PhabricatorSubscribableInterface  )----------------------------------- */","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/packages/storage/PhabricatorPackagesPublisher.php#L70-L106","documentation":"Thrown by PhabricatorPackagesPublisher::assertValidPublisherKey() when the publisher key is longer than 64 UTF-8 characters. Keys appear in URIs and are compared literally across the install, so they share the same 64-character ceiling as names even though their alphabet is much stricter.","triggerScenarios":"Creating a publisher whose key, after normalization or generation from a name, exceeds 64 UTF-8 characters; e.g. a slugified 80-character company name passed as publisherKey.","commonSituations":"Auto-generating keys from long display names without truncation; importing external identifiers (registry publisher ids) that exceed the cap.","solutions":["Shorten the key to 64 characters or fewer.","Prefer a short stable slug (e.g. 'acme') and keep the long form in the name/description fields.","Truncate generated keys with PhutilUTF8StringTruncator and re-validate before saving."],"exampleFix":"// before\n$key = strtolower(preg_replace('/[^a-zA-Z]+/', '', $very_long_vendor_name));\n\n// after\n$key = strtolower(preg_replace('/[^a-zA-Z]+/', '', $very_long_vendor_name));\n$key = id(new PhutilUTF8StringTruncator())\n  ->setMaximumGlyphs(64)\n  ->truncateString($key);\nPhabricatorPackagesPublisher::assertValidPublisherKey($key);","handlingStrategy":"validation","validationCode":"$max = 64;\nif (phutil_utf8_strlen($key) > $max) {\n  $key = id(new PhutilUTF8StringTruncator())\n    ->setMaximumGlyphs($max)\n    ->truncateString($key);\n}\nPhabricatorPackagesPublisher::assertValidPublisherKey($key);","typeGuard":"function is_valid_publisher_key_length($key) {\n  return is_string($key) && phutil_utf8_strlen($key) <= 64;\n}","tryCatchPattern":"try {\n  PhabricatorPackagesPublisher::assertValidPublisherKey($key);\n} catch (Exception $ex) {\n  $errors[] = $ex->getMessage();\n}","preventionTips":["Prefer short human-chosen slugs for keys instead of generated long ones.","Truncate any key derived from an external identifier before validation.","Count with phutil_utf8_strlen() so multibyte names do not surprise you."],"tags":["phabricator","packages","publisher","validation","utf-8"],"backgroundTag":"input-length-validation","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}