{"record":{"id":"1cef25bb58e35306","repo":"phacility/phabricator","slug":"version-name-s-is-not-valid-version-names-are","errorCode":null,"errorMessage":"Version name \"%s\" is not valid: version names are required.","messagePattern":"Version name \"(.+?)\" is not valid: version names are required\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/packages/storage/PhabricatorPackagesVersion.php","lineNumber":64,"sourceCode":"    $full_key = $package->getFullKey();\n    $name = $this->getName();\n\n    return \"/package/{$full_key}/{$name}/\";\n  }\n\n  public function attachPackage(PhabricatorPackagesPackage $package) {\n    $this->package = $package;\n    return $this;\n  }\n\n  public function getPackage() {\n    return $this->assertAttached($this->package);\n  }\n\n  public static function assertValidVersionName($value) {\n    $length = phutil_utf8_strlen($value);\n    if (!$length) {\n      throw new Exception(\n        pht(\n          'Version name \"%s\" is not valid: version names are required.',\n          $value));\n    }\n\n    $max_length = 64;\n    if ($length > $max_length) {\n      throw new Exception(\n        pht(\n          'Version name \"%s\" is not valid: version names must not be '.\n          'more than %s characters long.',\n          $value,\n          new PhutilNumber($max_length)));\n    }\n\n    if (!preg_match('/^[A-Za-z0-9.-]+\\z/', $value)) {\n      throw new Exception(\n        pht(","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/packages/storage/PhabricatorPackagesVersion.php#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Always set a concrete version name (e.g. the tag 'v1.0.2') before saving.","When importing tagless releases, synthesize a name or skip that row.","Check for a non-empty name before applying version transactions."],"exampleFix":"// before\n$xactions[] = id(new PhabricatorPackagesVersionTransaction())\n  ->setTransactionType(\n    PhabricatorPackagesVersionNameTransaction::TRANSACTIONTYPE)\n  ->setNewValue($name); // $name is null\n\n// after\nif (!phutil_utf8_strlen($name)) {\n  throw new Exception(pht('Version name is required.'));\n}\n$xactions[] = id(new PhabricatorPackagesVersionTransaction())\n  ->setTransactionType(\n    PhabricatorPackagesVersionNameTransaction::TRANSACTIONTYPE)\n  ->setNewValue($name);","handlingStrategy":"validation","validationCode":"if (!is_string($name) || !phutil_utf8_strlen($name)) {\n  throw new Exception(pht('Version name is required.'));\n}\nPhabricatorPackagesVersion::assertValidVersionName($name);","typeGuard":"function is_nonempty_version_name($name) {\n  return is_string($name) && phutil_utf8_strlen($name) > 0;\n}","tryCatchPattern":"try {\n  PhabricatorPackagesVersion::assertValidVersionName($name);\n} catch (Exception $ex) {\n  $errors[] = $ex->getMessage();\n}","preventionTips":["Make the version name field required in create/edit forms.","In importers, skip or synthesize a name for tagless releases instead of passing ''. ","Validate the whole triple (publisher, package, name) before applying version transactions."],"tags":["phabricator","packages","version","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"}