{"record":{"id":"b7f2f2db7bef6a0d","repo":"bettercap/bettercap","slug":"invalid-argument-not-valid-semver-version-re","errorCode":null,"errorMessage":"Invalid argument not valid semver ('${version}' received)","messagePattern":"Invalid argument not valid semver \\('(.+?)' received\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/ui/ui/vendor.js","lineNumber":91736,"sourceCode":"\n  function split(v) {\n    var c = v.replace(/^v/, '').replace(/\\+.*$/, '');\n    var patchIndex = indexOrEnd(c, '-');\n    var arr = c.substring(0, patchIndex).split('.');\n    arr.push(c.substring(patchIndex + 1));\n    return arr;\n  }\n\n  function tryParse(v) {\n    return isNaN(Number(v)) ? v : Number(v);\n  }\n\n  function validate(version) {\n    if (typeof version !== 'string') {\n      throw new TypeError('Invalid argument expected string');\n    }\n    if (!semver.test(version)) {\n      throw new Error('Invalid argument not valid semver (\\''+version+'\\' received)');\n    }\n  }\n\n  return function compareVersions(v1, v2) {\n    [v1, v2].forEach(validate);\n\n    var s1 = split(v1);\n    var s2 = split(v2);\n\n    for (var i = 0; i < Math.max(s1.length - 1, s2.length - 1); i++) {\n      var n1 = parseInt(s1[i] || 0, 10);\n      var n2 = parseInt(s2[i] || 0, 10);\n\n      if (n1 > n2) return 1;\n      if (n2 > n1) return -1;\n    }\n\n    var sp1 = s1[s1.length - 1];","sourceCodeStart":91718,"sourceCodeEnd":91754,"githubUrl":"https://github.com/bettercap/bettercap/blob/8eca2820f3c41d2004434ed5a291d87462caeeb7/modules/ui/ui/vendor.js#L91718-L91754","documentation":"Validation in the same semver utility's validate(): the argument is a string but fails the semver regular-expression test, so it cannot be parsed as MAJOR.MINOR.PATCH (with optional pre-release/build). Fired when users pass loose version strings like '1.2', 'v1', or free text.","triggerScenarios":"Thrown at modules/ui/ui/vendor.js:91736 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Normalize the version string before comparing (strip 'v' prefix, pad missing segments)","Validate the format against a semver regex before passing it to the comparison utility","Reject or log invalid versions at the input boundary instead of letting the utility throw"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"8eca2820f3c41d2004434ed5a291d87462caeeb7","analyzedAt":"2026-09-02T12:49:00.712Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}