{"record":{"id":"68f18155cc71774c","repo":"phacility/phabricator","slug":"version-name-s-is-not-valid-version-names-must","errorCode":null,"errorMessage":"Version name \"%s\" is not valid: version names must not be more than %s characters long.","messagePattern":"Version name \"(.+?)\" is not valid: version names must not be more than (.+?) characters long\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"src/applications/packages/storage/PhabricatorPackagesVersion.php","lineNumber":72,"sourceCode":"    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(\n          'Version name \"%s\" is not valid: version names may only contain '.\n          'latin letters, digits, periods, and hyphens.',\n          $value));\n    }\n\n    if (preg_match('/^[.-]|[.-]$/', $value)) {\n      throw new Exception(\n        pht(","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/packages/storage/PhabricatorPackagesVersion.php#L54-L90","documentation":"Thrown by PhabricatorPackagesVersion::assertValidVersionName() when the version name exceeds 64 UTF-8 characters. Even though version strings like '1.0.3-beta.2+build.2013-01-15' can get long, Phabricator caps them at 64 characters, counted per glyph via phutil_utf8_strlen().","triggerScenarios":"Creating a package version whose auto-generated or semver-plus-build-metadata name exceeds 64 characters, e.g. concatenating tag, channel, timestamp, and commit hash into the version name.","commonSituations":"CI scripts that build version labels from commit SHAs and timestamps; importing release streams that embed full build identifiers in the tag.","solutions":["Shorten the version name to 64 characters or fewer.","Move volatile build metadata (SHAs, timestamps) into the version description or a separate field rather than the name.","Truncate generated names with PhutilUTF8StringTruncator before validation."],"exampleFix":"// before\n$name = sprintf('%s+build.%s.%s', $tag, $date, $commit_sha); // 70+ chars\n\n// after\n$name = sprintf('%s+build.%s', $tag, substr($commit_sha, 0, 7));\nif (phutil_utf8_strlen($name) > 64) {\n  $name = id(new PhutilUTF8StringTruncator())\n    ->setMaximumGlyphs(64)\n    ->truncateString($name);\n}\nPhabricatorPackagesVersion::assertValidVersionName($name);","handlingStrategy":"validation","validationCode":"$max = 64;\nif (phutil_utf8_strlen($name) > $max) {\n  $name = id(new PhutilUTF8StringTruncator())\n    ->setMaximumGlyphs($max)\n    ->truncateString($name);\n}\nPhabricatorPackagesVersion::assertValidVersionName($name);","typeGuard":"function is_valid_version_name_length($name) {\n  return is_string($name) && phutil_utf8_strlen($name) <= 64;\n}","tryCatchPattern":"try {\n  PhabricatorPackagesVersion::assertValidVersionName($name);\n} catch (Exception $ex) {\n  $errors[] = $ex->getMessage();\n}","preventionTips":["Keep build metadata (SHAs, timestamps) out of the version name; use shorter forms.","Cap generated version labels at 64 glyphs before saving.","Use phutil_utf8_strlen() for the length check."],"tags":["phabricator","packages","version","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"}