phacility/phabricator · error · Exception

Version name "%s" is not valid: version names are required.

Error message

Version name "%s" is not valid: version names are required.

What it means

Thrown by PhabricatorPackagesVersion::assertValidVersionName() when the name of a package version is an empty string. Versions are identified by name within a package (the name is the tag/label users see, e.g. '1.0.0'), so a blank name cannot be stored and the editor rejects it up front.

Source

Thrown at src/applications/packages/storage/PhabricatorPackagesVersion.php:64

    $full_key = $package->getFullKey();
    $name = $this->getName();

    return "/package/{$full_key}/{$name}/";
  }

  public function attachPackage(PhabricatorPackagesPackage $package) {
    $this->package = $package;
    return $this;
  }

  public function getPackage() {
    return $this->assertAttached($this->package);
  }

  public static function assertValidVersionName($value) {
    $length = phutil_utf8_strlen($value);
    if (!$length) {
      throw new Exception(
        pht(
          'Version name "%s" is not valid: version names are required.',
          $value));
    }

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

    if (!preg_match('/^[A-Za-z0-9.-]+\z/', $value)) {
      throw new Exception(
        pht(

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Always set a concrete version name (e.g. the tag 'v1.0.2') before saving.
  2. When importing tagless releases, synthesize a name or skip that row.
  3. Check for a non-empty name before applying version transactions.

Example fix

// before
$xactions[] = id(new PhabricatorPackagesVersionTransaction())
  ->setTransactionType(
    PhabricatorPackagesVersionNameTransaction::TRANSACTIONTYPE)
  ->setNewValue($name); // $name is null

// after
if (!phutil_utf8_strlen($name)) {
  throw new Exception(pht('Version name is required.'));
}
$xactions[] = id(new PhabricatorPackagesVersionTransaction())
  ->setTransactionType(
    PhabricatorPackagesVersionNameTransaction::TRANSACTIONTYPE)
  ->setNewValue($name);
Defensive patterns

Strategy: validation

Validate before calling

if (!is_string($name) || !phutil_utf8_strlen($name)) {
  throw new Exception(pht('Version name is required.'));
}
PhabricatorPackagesVersion::assertValidVersionName($name);

Type guard

function is_nonempty_version_name($name) {
  return is_string($name) && phutil_utf8_strlen($name) > 0;
}

Try / catch

try {
  PhabricatorPackagesVersion::assertValidVersionName($name);
} catch (Exception $ex) {
  $errors[] = $ex->getMessage();
}

Prevention

When it happens

Trigger: Creating a PhabricatorPackagesVersion through the version editor, web form, or import script where the publisher and package are set but the name is '', null, or whitespace-only.

Common situations: Importers hitting external releases that carry no tag or name; forms where the name field was treated as optional; variables read from a missing array key defaulting to empty.

Related errors


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