phacility/phabricator · error · Exception

Publisher key "%s" is not valid: publisher keys are required

Error message

Publisher key "%s" is not valid: publisher keys are required.

What it means

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.

Source

Thrown at src/applications/packages/storage/PhabricatorPackagesPublisher.php:80

          'Publisher name "%s" is not valid: publisher names are required.',
          $value));
    }

    $max_length = 64;
    if ($length > $max_length) {
      throw new Exception(
        pht(
          'Publisher name "%s" is not valid: publisher names must not be '.
          'more than %s characters long.',
          $value,
          new PhutilNumber($max_length)));
    }
  }

  public static function assertValidPublisherKey($value) {
    $length = phutil_utf8_strlen($value);
    if (!$length) {
      throw new Exception(
        pht(
          'Publisher key "%s" is not valid: publisher keys are required.',
          $value));
    }

    $max_length = 64;
    if ($length > $max_length) {
      throw new Exception(
        pht(
          'Publisher key "%s" is not valid: publisher keys must not be '.
          'more than %s characters long.',
          $value,
          new PhutilNumber($max_length)));
    }

    if (!preg_match('/^[a-z]+\z/', $value)) {
      throw new Exception(
        pht(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Set a non-empty publisher key before saving.
  2. Derive the key automatically from the name (lowercase letters only) when the user does not supply one.
  3. Reject the request client-side when the key field is empty instead of letting the editor throw.

Example fix

// before
$key = '';
PhabricatorPackagesPublisher::assertValidPublisherKey($key);

// after
if (!phutil_utf8_strlen($key)) {
  $key = preg_replace('/[^a-z]+/', '', strtolower($name));
}
PhabricatorPackagesPublisher::assertValidPublisherKey($key);
Defensive patterns

Strategy: validation

Validate before calling

if (!is_string($key) || !phutil_utf8_strlen($key)) {
  $key = preg_replace('/[^a-z]+/', '', strtolower($name));
}
PhabricatorPackagesPublisher::assertValidPublisherKey($key);

Type guard

function is_nonempty_publisher_key($key) {
  return is_string($key) && phutil_utf8_strlen($key) > 0;
}

Try / catch

try {
  PhabricatorPackagesPublisher::assertValidPublisherKey($key);
} catch (Exception $ex) {
  $errors[] = $ex->getMessage();
}

Prevention

When it happens

Trigger: Applying publisher-create or publisher-edit transactions through PhabricatorPackagesPublisherEditor with publisherKey set to '', null, or a value that coerces to empty (whitespace-only string).

Common situations: 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.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/f1a11833f11e6fd7. Report an issue: GitHub.