bettercap/bettercap · error
Invalid argument not valid semver ('${version}' received)
Error message
Invalid argument not valid semver ('${version}' received) What it means
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.
Source
Thrown at modules/ui/ui/vendor.js:91736
function split(v) {
var c = v.replace(/^v/, '').replace(/\+.*$/, '');
var patchIndex = indexOrEnd(c, '-');
var arr = c.substring(0, patchIndex).split('.');
arr.push(c.substring(patchIndex + 1));
return arr;
}
function tryParse(v) {
return isNaN(Number(v)) ? v : Number(v);
}
function validate(version) {
if (typeof version !== 'string') {
throw new TypeError('Invalid argument expected string');
}
if (!semver.test(version)) {
throw new Error('Invalid argument not valid semver (\''+version+'\' received)');
}
}
return function compareVersions(v1, v2) {
[v1, v2].forEach(validate);
var s1 = split(v1);
var s2 = split(v2);
for (var i = 0; i < Math.max(s1.length - 1, s2.length - 1); i++) {
var n1 = parseInt(s1[i] || 0, 10);
var n2 = parseInt(s2[i] || 0, 10);
if (n1 > n2) return 1;
if (n2 > n1) return -1;
}
var sp1 = s1[s1.length - 1];View on GitHub (pinned to 8eca2820f3)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at modules/ui/ui/vendor.js:91736 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of bettercap/bettercap@8eca2820f3 (2026-09-02).
Data as JSON: /api/errors/b7f2f2db7bef6a0d.
Report an issue: GitHub.