stamparm/maltrail · error · SystemExit

[!] %r is not 'major.minor' - Maltrail versions two…

Error message

[!] %r is not 'major.minor' - Maltrail versions two components

What it means

main() validates the final target version (explicit --version or computed via --next) against ^\d+\.\d+$. Maltrail's versioning scheme is strictly two components (major.minor), so anything else - pre-release suffixes, three-part semver, or non-numeric parts - is rejected before any file is touched.

Solutions

  1. Pass exactly two numeric components: python bump_version.py --version 0.54.
  2. Remove prefixes/suffixes (v, -rc1, +build) from the version string before invoking the script.
  3. If you genuinely need three-component versions, this tool's contract must change - update the regex and next_minor(), but note Maltrail upstream uses major.minor only.

Example fix

// before
$ python bump_version.py --version 0.5.3
// after
$ python bump_version.py --version 0.54
Defensive patterns

Strategy: validation

Validate before calling

import re
def valid_target(v: str) -> bool:
    return bool(re.match(r'^\d+\.\d+$', v))
assert valid_target('0.54'), 'pass a major.minor version, e.g. --version 0.54'

Type guard

import re
def is_maltrail_version(v: str) -> bool:
    return isinstance(v, str) and re.match(r'^\d+\.\d+$', v) is not None

Try / catch

try:
    bump_version.main(['--version', args.version])
except SystemExit as e:
    if "is not 'major.minor'" in str(e):
        print('Use a two-component version, e.g. --version 0.54')

Prevention

When it happens

Trigger: Running `python bump_version.py --version 0.5.3`, `--version 0.5-rc1`, `--version v0.5`, or otherwise passing a string that is not exactly digits.digits.

Common situations: A developer habitually uses semver with three components or pre-release tags in other projects and applies it here; CI scripts pass a build-stamped version; a tag prefix like 'v' is included.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of stamparm/maltrail@77cfb06d76 (2026-09-13). Data as JSON: /api/errors/95d4b0145bc4559c. Report an issue: GitHub.

Appendix: source

Thrown at sensor/tools/bump_version.py:135

def main():
    parser = argparse.ArgumentParser(description="set Maltrail's version in every file that carries it")
    parser.add_argument("version", nargs="?", help="the new version, e.g. 3.3")
    parser.add_argument("--next", action="store_true", help="bump the minor component of the current version")
    parser.add_argument("--check", action="store_true", help="verify only; write nothing")
    parser.add_argument("--date", help="also set CITATION.cff date-released (YYYY-MM-DD, or 'today')")
    args = parser.parse_args()

    if args.check:
        if args.version or args.next:
            parser.error("--check takes no version")
        return _verify()

    if args.next == bool(args.version):
        parser.error("give a version, or --next, but not both")

    version = next_minor(current()) if args.next else args.version
    if not re.match(r'^\d+\.\d+$', version):
        raise SystemExit("[!] %r is not 'major.minor' - Maltrail versions two components" % version)

    date = args.date
    if date == "today":
        date = datetime.date.today().isoformat()
    if date and not re.match(r'^\d{4}-\d{2}-\d{2}$', date):
        raise SystemExit("[!] --date must be YYYY-MM-DD")

    print("[i] %s -> %s" % (current(), version))
    apply(version, date)
    return _verify()


def _verify():
    """Hand off to the checker rather than re-implementing agreement here.

    argv is swapped for the call: check_version parses sys.argv itself, and would otherwise
    reject the flags that were meant for THIS script.
    """

View on GitHub (pinned to 77cfb06d76)