{"record":{"id":"6c19c71941105004","repo":"phacility/phabricator","slug":"publisher-name-s-is-not-valid-publisher-names-6c19c7","errorCode":null,"errorMessage":"Publisher name \"%s\" is not valid: publisher names must not be more than %s characters long.","messagePattern":"Publisher name \"(.+?)\" is not valid: publisher names must not be more than (.+?) characters long\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/packages/storage/PhabricatorPackagesPublisher.php","lineNumber":68,"sourceCode":"  }\n\n  public function getURI() {\n    $publisher_key = $this->getPublisherKey();\n    return \"/package/{$publisher_key}/\";\n  }\n\n  public static function assertValidPublisherName($value) {\n    $length = phutil_utf8_strlen($value);\n    if (!$length) {\n      throw new Exception(\n        pht(\n          '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;","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/packages/storage/PhabricatorPackagesPublisher.php#L50-L86","documentation":"Thrown by PhabricatorPackagesPublisher::assertValidPublisherName() when validating the display name of a Packages publisher. Publisher names are free-form text but must be non-empty and at most 64 UTF-8 characters long, measured with phutil_utf8_strlen() so multi-byte glyphs count as one character each. The publisher editor runs this assertion before applying transactions, so an over-long name is rejected before it reaches storage.","triggerScenarios":"Creating or editing a publisher via PhabricatorPackagesPublisherEditor (web form at Packages > Create Publisher, HTTP API, or seeding script) with a name whose UTF-8 length exceeds 64, e.g. a 70-character company-plus-product title.","commonSituations":"Bulk-importing publishers from an external registry (npm scopes, Maven group ids, long vendor names) that imposes no length cap; migration scripts copying display names verbatim; generated test fixtures with long strings.","solutions":["Shorten the publisher name to 64 characters or fewer (count multi-byte characters as one).","If the full long text matters, move it into the publisher description field, which has no such tight limit.","When importing, truncate programmatically with PhutilUTF8StringTruncator before feeding the editor.","Add a client-side length check in the form so users get a friendly message instead of a raw exception."],"exampleFix":"// before\n$xactions[] = id(new PhabricatorPackagesPublisherTransaction())\n  ->setTransactionType(\n    PhabricatorPackagesPublisherNameTransaction::TRANSACTIONTYPE)\n  ->setNewValue($name); // $name is 70 characters long\n\n// after\nif (phutil_utf8_strlen($name) > 64) {\n  $name = id(new PhutilUTF8StringTruncator())\n    ->setMaximumGlyphs(64)\n    ->truncateString($name);\n}\n$xactions[] = id(new PhabricatorPackagesPublisherTransaction())\n  ->setTransactionType(\n    PhabricatorPackagesPublisherNameTransaction::TRANSACTIONTYPE)\n  ->setNewValue($name);","handlingStrategy":"validation","validationCode":"$max = 64;\nif (!is_string($name) || !phutil_utf8_strlen($name)) {\n  // reject before saving\n} elseif (phutil_utf8_strlen($name) > $max) {\n  $name = id(new PhutilUTF8StringTruncator())\n    ->setMaximumGlyphs($max)\n    ->truncateString($name);\n}\nPhabricatorPackagesPublisher::assertValidPublisherName($name);","typeGuard":"function is_valid_publisher_name($name) {\n  return is_string($name)\n    && phutil_utf8_strlen($name) > 0\n    && phutil_utf8_strlen($name) <= 64;\n}","tryCatchPattern":"try {\n  PhabricatorPackagesPublisher::assertValidPublisherName($name);\n} catch (Exception $ex) {\n  $errors[] = $ex->getMessage(); // surface as a form validation error\n}","preventionTips":["Cap the publisher name input at 64 characters in the form's maxlength/UX.","Measure length with phutil_utf8_strlen(), never strlen(), before saving.","Run assertValidPublisherName() on all imported data before applying transactions."],"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"}