{"record":{"id":"3727dd1e3cf29708","repo":"stamparm/maltrail","slug":"no-version-key-in-the-package-table-of-s","errorCode":null,"errorMessage":"[!] no version key in the [package] table of %s","messagePattern":"\\[!\\] no version key in the \\[package\\] table of (.+?)","errorType":"console","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"sensor/tools/check_version.py","lineNumber":56,"sourceCode":"\n\ndef settings_version():\n    \"\"\"VERSION = \"3.0\" from core/settings.py, without importing it (it has side effects).\"\"\"\n    match = re.search(r\"^VERSION\\s*=\\s*[\\\"']([^\\\"']+)[\\\"']\", _read(SETTINGS), re.M)\n    if not match:\n        raise SystemExit(\"[!] no VERSION assignment found in %s\" % SETTINGS)\n    return match.group(1)\n\n\ndef cargo_version():\n    \"\"\"version = \"3.0.0\" from the [package] table only - dependency versions must not match.\"\"\"\n    text = _read(CARGO)\n    package = re.search(r\"^\\[package\\]\\s*$(.*?)(?=^\\[|\\Z)\", text, re.M | re.S)\n    if not package:\n        raise SystemExit(\"[!] no [package] table found in %s\" % CARGO)\n    match = re.search(r\"^version\\s*=\\s*\\\"([^\\\"]+)\\\"\", package.group(1), re.M)\n    if not match:\n        raise SystemExit(\"[!] no version key in the [package] table of %s\" % CARGO)\n    return match.group(1)\n\n\ndef citation_version():\n    \"\"\"version: \"3.0\" from CITATION.cff.\n\n    Nothing linked this to the tree, and it drifted: the file still claimed 3.0 while the code,\n    the sensor and the published tag were all 3.1.1. That is not cosmetic - CITATION.cff exists\n    so a paper can cite a specific version, and it had been quietly citing the wrong one.\n    \"\"\"\n\n    match = re.search(r\"^version\\s*:\\s*[\\\"']([^\\\"']+)[\\\"']\", _read(CITATION), re.M)\n    if not match:\n        raise SystemExit(\"[!] no version key found in %s\" % CITATION)\n    return match.group(1)\n\n\ndef settings_gen_version():","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/stamparm/maltrail/blob/77cfb06d7606506d101bbcec0786c77166c4255e/sensor/tools/check_version.py#L38-L74","documentation":"cargo_version() in check_version.py successfully locates the [package] table in Cargo.toml but then fails to find a version = \"...\" key inside that table's body, so it raises SystemExit with this message. Cargo requires every package to declare a version, and this checker mirrors that requirement to compare it against VERSION in settings.py.","triggerScenarios":"The [package] table exists but has no version key at line start (e.g. version was removed in an edit, is written as \"version\" = ... with quotes on the key, is indented under another table, or uses a workspace-inherited version = { workspace = true } declaration the literal-string regex cannot read).","commonSituations":"A refactor moved version into a workspace-level [workspace.package] table with version.workspace = true in members; a hand edit accidentally deleted the version line; the version key was misspelled (versions, verison) or placed after the next [section] header so it's outside the captured package body.","solutions":["Add a version key inside the [package] table, e.g. version = \"3.0.0\", on its own line before the next [section] header.","If the crate inherits version from the workspace (version.workspace = true), inline a literal version in [package] or extend cargo_version() to resolve the workspace value, since the checker only matches plain string literals.","Fix misspellings of the key and ensure it is not indented or commented out.","Run cargo verify-project (or cargo metadata) to confirm the manifest is structurally valid, then re-run the check."],"exampleFix":"# before (Cargo.toml)\n[package]\nname = \"sensor\"\nedition = \"2021\"\n# after\n[package]\nname = \"sensor\"\nversion = \"3.0.0\"\nedition = \"2021\"","handlingStrategy":"validation","validationCode":"import re\ntext = open(\"Cargo.toml\").read()\nm = re.search(r'^\\[package\\]\\s*$(.*?)(?=^\\[|\\Z)', text, re.M | re.S)\nassert m and re.search(r'^version\\s*=\\s*\"[^\"]+\"', m.group(1), re.M), \\\n    \"[package] table must declare a literal version = \\\"x.y.z\\\"\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always declare version = \"x.y.z\" directly in [package]; avoid version.workspace = true unless the checker is updated to resolve it.","Generate releases via cargo-release or cargo set-version so the version key is never accidentally removed.","Spell the key exactly as lowercase 'version' at line start, unindented, inside the [package] table (before the next [section]).","Add a CI lint that parses Cargo.toml with toml and asserts package.version exists and parses as semver."],"tags":["cargo","toml","versioning","manifest"],"backgroundTag":"missing-required-config-field","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"}