{"record":{"id":"ea88cf6817fd5ec0","repo":"nats-io/nats-server","slug":"invalid-semver","errorCode":null,"errorMessage":"invalid semver","messagePattern":"invalid semver","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/util.go","lineNumber":46,"sourceCode":"\t\"strconv\"\n\t\"strings\"\n\t\"time\"\n)\n\n// This map is used to store URLs string as the key with a reference count as\n// the value. This is used to handle gossiped URLs such as connect_urls, etc..\ntype refCountedUrlSet map[string]int\n\n// Ascii numbers 0-9\nconst (\n\tasciiZero = 48\n\tasciiNine = 57\n)\n\nfunc versionComponents(version string) (major, minor, patch int, err error) {\n\tm := semVerRe.FindStringSubmatch(version)\n\tif len(m) == 0 {\n\t\treturn 0, 0, 0, errors.New(\"invalid semver\")\n\t}\n\tmajor, err = strconv.Atoi(m[1])\n\tif err != nil {\n\t\treturn -1, -1, -1, err\n\t}\n\tminor, err = strconv.Atoi(m[2])\n\tif err != nil {\n\t\treturn -1, -1, -1, err\n\t}\n\tpatch, err = strconv.Atoi(m[3])\n\tif err != nil {\n\t\treturn -1, -1, -1, err\n\t}\n\treturn major, minor, patch, err\n}\n\nfunc versionAtLeastCheckError(version string, emajor, eminor, epatch int) (bool, error) {\n\tmajor, minor, patch, err := versionComponents(version)","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/util.go#L28-L64","documentation":"versionComponents: the version string did not match the semver regex (no major.minor.patch captured), so version comparisons — leaf-node minimum-version checks, trusted-operator validation — fail. The unparsable version string from config or peer info is the input at fault.","triggerScenarios":"Thrown at server/util.go:46 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use full semver strings like 2.10.0 in minimum-version settings","Fix or remove malformed version fields from operator/leafnode configuration","Strip prefixes such as 'v' before comparing if needed"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}