{"record":{"id":"f1a11833f11e6fd7","repo":"phacility/phabricator","slug":"publisher-key-s-is-not-valid-publisher-keys-ar","errorCode":null,"errorMessage":"Publisher key \"%s\" is not valid: publisher keys are required.","messagePattern":"Publisher key \"(.+?)\" is not valid: publisher keys are required\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/packages/storage/PhabricatorPackagesPublisher.php","lineNumber":80,"sourceCode":"          'Publisher name \"%s\" is not valid: publisher names are required.',\n          $value));\n    }\n\n    $max_length = 64;\n    if ($length > $max_length) {\n      throw new Exception(\n        pht(\n          '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(","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/packages/storage/PhabricatorPackagesPublisher.php#L62-L98","documentation":"Thrown by PhabricatorPackagesPublisher::assertValidPublisherKey() when the publisher key (the permanent machine-readable identifier used in URIs and package namespaces) is an empty string. Keys are required because they build the canonical /packages/<key>/... URL space and are matched literally; unlike display names they can never be blank.","triggerScenarios":"Applying publisher-create or publisher-edit transactions through PhabricatorPackagesPublisherEditor with publisherKey set to '', null, or a value that coerces to empty (whitespace-only string).","commonSituations":"Import scripts that map a missing external identifier to an empty string; UI forms where the key field was left blank because the developer assumed the name would be used as a fallback.","solutions":["Set a non-empty publisher key before saving.","Derive the key automatically from the name (lowercase letters only) when the user does not supply one.","Reject the request client-side when the key field is empty instead of letting the editor throw."],"exampleFix":"// before\n$key = '';\nPhabricatorPackagesPublisher::assertValidPublisherKey($key);\n\n// after\nif (!phutil_utf8_strlen($key)) {\n  $key = preg_replace('/[^a-z]+/', '', strtolower($name));\n}\nPhabricatorPackagesPublisher::assertValidPublisherKey($key);","handlingStrategy":"validation","validationCode":"if (!is_string($key) || !phutil_utf8_strlen($key)) {\n  $key = preg_replace('/[^a-z]+/', '', strtolower($name));\n}\nPhabricatorPackagesPublisher::assertValidPublisherKey($key);","typeGuard":"function is_nonempty_publisher_key($key) {\n  return is_string($key) && phutil_utf8_strlen($key) > 0;\n}","tryCatchPattern":"try {\n  PhabricatorPackagesPublisher::assertValidPublisherKey($key);\n} catch (Exception $ex) {\n  $errors[] = $ex->getMessage();\n}","preventionTips":["Make the key field required in the UI and reject blank submits client-side.","Default import scripts to deriving a key from the name rather than an empty string.","Validate both name and key in one pass with the assert methods before editing."],"tags":["phabricator","packages","publisher","required-field","validation"],"backgroundTag":"required-field-missing","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}