stamparm/maltrail · error · SystemExit

[!] --date must be YYYY-MM-DD

Error message

[!] --date must be YYYY-MM-DD

What it means

This exit error comes from bump_version.py's main() argument validation. The tool accepts an --date argument that must be either the literal string 'today' or a date in strict YYYY-MM-DD form; it validates with the regex ^\d{4}-\d{2}-\d{2}$ before applying the new version. If --date is supplied in any other format, the script refuses to run and exits via SystemExit, preventing a malformed release date from being written into version metadata.

Solutions

  1. Re-run with --date in strict YYYY-MM-DD form, e.g. --date 2026-09-12 (zero-pad month and day).
  2. If you want the current date, pass the literal string --date today and the tool resolves it via datetime.date.today().isoformat().
  3. In automation, generate the date with date +%F (shell) or datetime.date.today().isoformat() (Python) instead of hand-formatting it.
  4. Sanitize any timestamp from upstream systems by taking only the first 10 characters of the ISO string, after verifying the prefix matches YYYY-MM-DD.

Example fix

// before
python sensor/tools/bump_version.py 3.1 --date 09/12/2026
// after
python sensor/tools/bump_version.py 3.1 --date 2026-09-12
Defensive patterns

Strategy: validation

Validate before calling

import datetime, re
def valid_bump_date(d):
    if d == "today":
        return True
    return bool(re.match(r'^\d{4}-\d{2}-\d{2}$', d))

date = "09/12/2026"
if not valid_bump_date(date):
    raise SystemExit("use YYYY-MM-DD or 'today'")

Type guard

import re
def is_iso_date(s: str) -> bool:
    if not isinstance(s, str) or not re.match(r'^\d{4}-\d{2}-\d{2}$', s):
        return False
    try:
        datetime.date.fromisoformat(s)
        return True
    except ValueError:
        return False

Prevention

When it happens

Trigger: Running the bump-version tool with --date set to anything that is not 'today' and does not match exactly four digits, dash, two digits, dash, two digits — e.g. --date 2026/09/12, --date 12-09-2026, --date Sep 12 2026, or --date 2026-9-12 (single-digit month/day).

Common situations: Developers habitually type dates in their locale's format (DD-MM-YYYY or MM/DD/YYYY), use human-readable dates, or omit zero-padding for single-digit months/days. CI release scripts built for other tools may pass ISO timestamps like 2026-09-12T00:00:00Z, which also fail the strict pattern.

Related errors


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

Appendix: source

Thrown at sensor/tools/bump_version.py:141

    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.
    """

    sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
    import check_version
    argv = sys.argv
    try:
        sys.argv = [check_version.__file__]

View on GitHub (pinned to 77cfb06d76)