{"record":{"id":"5f0dc473879e6efb","repo":"stamparm/maltrail","slug":"date-must-be-yyyy-mm-dd","errorCode":null,"errorMessage":"[!] --date must be YYYY-MM-DD","messagePattern":"\\[!\\] --date must be YYYY-MM-DD","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"sensor/tools/bump_version.py","lineNumber":141,"sourceCode":"    args = parser.parse_args()\n\n    if args.check:\n        if args.version or args.next:\n            parser.error(\"--check takes no version\")\n        return _verify()\n\n    if args.next == bool(args.version):\n        parser.error(\"give a version, or --next, but not both\")\n\n    version = next_minor(current()) if args.next else args.version\n    if not re.match(r'^\\d+\\.\\d+$', version):\n        raise SystemExit(\"[!] %r is not 'major.minor' - Maltrail versions two components\" % version)\n\n    date = args.date\n    if date == \"today\":\n        date = datetime.date.today().isoformat()\n    if date and not re.match(r'^\\d{4}-\\d{2}-\\d{2}$', date):\n        raise SystemExit(\"[!] --date must be YYYY-MM-DD\")\n\n    print(\"[i] %s -> %s\" % (current(), version))\n    apply(version, date)\n    return _verify()\n\n\ndef _verify():\n    \"\"\"Hand off to the checker rather than re-implementing agreement here.\n\n    argv is swapped for the call: check_version parses sys.argv itself, and would otherwise\n    reject the flags that were meant for THIS script.\n    \"\"\"\n\n    sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))\n    import check_version\n    argv = sys.argv\n    try:\n        sys.argv = [check_version.__file__]","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/stamparm/maltrail/blob/77cfb06d7606506d101bbcec0786c77166c4255e/sensor/tools/bump_version.py#L123-L159","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Re-run with --date in strict YYYY-MM-DD form, e.g. --date 2026-09-12 (zero-pad month and day).","If you want the current date, pass the literal string --date today and the tool resolves it via datetime.date.today().isoformat().","In automation, generate the date with date +%F (shell) or datetime.date.today().isoformat() (Python) instead of hand-formatting it.","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."],"exampleFix":"// before\npython sensor/tools/bump_version.py 3.1 --date 09/12/2026\n// after\npython sensor/tools/bump_version.py 3.1 --date 2026-09-12","handlingStrategy":"validation","validationCode":"import datetime, re\ndef valid_bump_date(d):\n    if d == \"today\":\n        return True\n    return bool(re.match(r'^\\d{4}-\\d{2}-\\d{2}$', d))\n\ndate = \"09/12/2026\"\nif not valid_bump_date(date):\n    raise SystemExit(\"use YYYY-MM-DD or 'today'\")","typeGuard":"import re\ndef is_iso_date(s: str) -> bool:\n    if not isinstance(s, str) or not re.match(r'^\\d{4}-\\d{2}-\\d{2}$', s):\n        return False\n    try:\n        datetime.date.fromisoformat(s)\n        return True\n    except ValueError:\n        return False","tryCatchPattern":null,"preventionTips":["Always generate release dates programmatically (date +%F or datetime.date.today().isoformat()) instead of typing them.","Validate dates with datetime.date.fromisoformat() before passing to scripts, so impossible dates like 2026-02-31 are caught too.","Wrap the bump tool in a small shell/CI wrapper that normalizes locale-formatted dates to ISO 8601.","Prefer passing the literal 'today' when the release is happening now."],"tags":["cli","validation","date-format","release-tooling"],"backgroundTag":"invalid-date-format","analyzedSha":"77cfb06d7606506d101bbcec0786c77166c4255e","analyzedAt":"2026-09-13T03:50:16.010Z","contentChangedAt":"2026-09-13T03:50:16.010Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}