{"record":{"id":"8aa150bf968f4f51","repo":"phar-io/version","slug":"invalid-label-s","errorCode":null,"errorMessage":"Invalid label %s","messagePattern":"Invalid label (.+?)","errorType":"exception","errorClass":"InvalidPreReleaseSuffixException","httpStatus":null,"severity":"error","filePath":"src/PreReleaseSuffix.php","lineNumber":70,"sourceCode":"\n        if ($this->valueScore < $suffix->valueScore) {\n            return false;\n        }\n\n        return $this->getNumber() > $suffix->getNumber();\n    }\n\n    private function mapValueToScore(string $value): int {\n        $value = \\strtolower($value);\n\n        return self::valueScoreMap[$value];\n    }\n\n    private function parseValue(string $value): void {\n        $regex = '/-?((dev|beta|b|rc|alpha|a|patch|p|pl)\\.?(\\d*)).*$/i';\n\n        if (\\preg_match($regex, $value, $matches) !== 1) {\n            throw new InvalidPreReleaseSuffixException(\\sprintf('Invalid label %s', $value));\n        }\n\n        $this->full  = $matches[1];\n        $this->value = $matches[2];\n\n        if ($matches[3] !== '') {\n            $this->number = (int)$matches[3];\n        }\n\n        $this->valueScore = $this->mapValueToScore($matches[2]);\n    }\n}\n","sourceCodeStart":52,"sourceCodeEnd":83,"githubUrl":"https://github.com/phar-io/version/blob/5eeb03f1ee82b3076d72daa5cb85d6b68abad783/src/PreReleaseSuffix.php#L52-L83","documentation":"InvalidPreReleaseSuffixException with 'Invalid label %s' is thrown by PreReleaseSuffix::parseValue when the pre-release portion of a version string does not match the regex of known labels (dev, beta, b, rc, alpha, a, patch, p, pl), each optionally followed by a number. The library only recognizes these standard labels for ordering pre-release versions. Any other label, such as 'nightly', 'canary' or a bare number, is rejected.","triggerScenarios":"Calling new Version('1.0.0-nightly') or any string whose pre-release suffix fails '/-?((dev|beta|b|rc|alpha|a|patch|p|pl)\\.?(\\d*)).*$/i'. Passing a constraint like '1.0.0-preview.1' to VersionConstraintParser which forwards it to Version construction.","commonSituations":"Parsing versions from package registries or git tags that use non-SemVer pre-release labels (e.g. '1.2.0-nightly.20240101'); CI builds tagging builds with custom suffixes like 'ci' or 'sha.abc123'; hand-written version constraints with typos such as '1.0.0-bta'.","solutions":["Rename the pre-release suffix to a supported label: dev, alpha (a), beta (b), rc, patch (p/pl), optionally with a numeric part, e.g. '1.0.0-beta.2'.","Strip or remap the unsupported suffix before constructing the Version, mapping vendor labels to SemVer ones (nightly -> dev).","If the string is external input, validate it against the SemVer pre-release grammar first and show a clear error instead of letting the constructor throw."],"exampleFix":"// before\n$version = new Version('2.1.0-nightly');\n\n// after\n$version = new Version('2.1.0-dev'); // or '2.1.0-dev.3'","handlingStrategy":"validation","validationCode":"// PHP\nif (!preg_match('/-?((dev|beta|b|rc|alpha|a|patch|p|pl)\\.?(\\d*)).*$/i', $suffix)) {\n    throw new InvalidArgumentException(\"Unsupported pre-release label: $suffix\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    $version = new Version($input);\n} catch (InvalidPreReleaseSuffixException $e) {\n    // reject or remap the suffix\n}","preventionTips":["Map vendor-specific labels (nightly, canary, snapshot) to SemVer labels before constructing a Version.","Favor standard labels alpha/beta/rc with numeric increments for CI builds.","Validate external version strings at the boundary of your application, not deep in business logic."],"tags":["semver","pre-release","version-parsing","php"],"backgroundTag":"invalid-enum-value","analyzedSha":"5eeb03f1ee82b3076d72daa5cb85d6b68abad783","analyzedAt":"2026-09-14T11:12:29.257Z","contentChangedAt":"2026-09-14T11:12:29.257Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}