phacility/phabricator · error · Exception

Publisher key "%s" is not valid: publisher keys must not be

Error message

Publisher key "%s" is not valid: publisher keys must not be more than %s characters long.

What it means

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.

Source

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

          '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(
          'Publisher key "%s" is not valid: publisher keys may only contain '.
          'lowercase latin letters.',
          $value));
    }
  }


/* -(  PhabricatorSubscribableInterface  )----------------------------------- */

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Shorten the key to 64 characters or fewer.
  2. Prefer a short stable slug (e.g. 'acme') and keep the long form in the name/description fields.
  3. Truncate generated keys with PhutilUTF8StringTruncator and re-validate before saving.

Example fix

// before
$key = strtolower(preg_replace('/[^a-zA-Z]+/', '', $very_long_vendor_name));

// after
$key = strtolower(preg_replace('/[^a-zA-Z]+/', '', $very_long_vendor_name));
$key = id(new PhutilUTF8StringTruncator())
  ->setMaximumGlyphs(64)
  ->truncateString($key);
PhabricatorPackagesPublisher::assertValidPublisherKey($key);
Defensive patterns

Strategy: validation

Validate before calling

$max = 64;
if (phutil_utf8_strlen($key) > $max) {
  $key = id(new PhutilUTF8StringTruncator())
    ->setMaximumGlyphs($max)
    ->truncateString($key);
}
PhabricatorPackagesPublisher::assertValidPublisherKey($key);

Type guard

function is_valid_publisher_key_length($key) {
  return is_string($key) && phutil_utf8_strlen($key) <= 64;
}

Try / catch

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

Prevention

When it happens

Trigger: 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.

Common situations: Auto-generating keys from long display names without truncation; importing external identifiers (registry publisher ids) that exceed the cap.

Related errors


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