stamparm/maltrail · error · SystemExit

[!] no version key in the [package] table of

Error message

[!] no version key in the [package] table of %s

What it means

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.

Solutions

  1. Add a version key inside the [package] table, e.g. version = "3.0.0", on its own line before the next [section] header.
  2. 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.
  3. Fix misspellings of the key and ensure it is not indented or commented out.
  4. Run cargo verify-project (or cargo metadata) to confirm the manifest is structurally valid, then re-run the check.

Example fix

# before (Cargo.toml)
[package]
name = "sensor"
edition = "2021"
# after
[package]
name = "sensor"
version = "3.0.0"
edition = "2021"
Defensive patterns

Strategy: validation

Validate before calling

import re
text = open("Cargo.toml").read()
m = re.search(r'^\[package\]\s*$(.*?)(?=^\[|\Z)', text, re.M | re.S)
assert m and re.search(r'^version\s*=\s*"[^"]+"', m.group(1), re.M), \
    "[package] table must declare a literal version = \"x.y.z\""

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.

Related errors


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

Appendix: source

Thrown at sensor/tools/check_version.py:56


def settings_version():
    """VERSION = "3.0" from core/settings.py, without importing it (it has side effects)."""
    match = re.search(r"^VERSION\s*=\s*[\"']([^\"']+)[\"']", _read(SETTINGS), re.M)
    if not match:
        raise SystemExit("[!] no VERSION assignment found in %s" % SETTINGS)
    return match.group(1)


def cargo_version():
    """version = "3.0.0" from the [package] table only - dependency versions must not match."""
    text = _read(CARGO)
    package = re.search(r"^\[package\]\s*$(.*?)(?=^\[|\Z)", text, re.M | re.S)
    if not package:
        raise SystemExit("[!] no [package] table found in %s" % CARGO)
    match = re.search(r"^version\s*=\s*\"([^\"]+)\"", package.group(1), re.M)
    if not match:
        raise SystemExit("[!] no version key in the [package] table of %s" % CARGO)
    return match.group(1)


def citation_version():
    """version: "3.0" from CITATION.cff.

    Nothing linked this to the tree, and it drifted: the file still claimed 3.0 while the code,
    the sensor and the published tag were all 3.1.1. That is not cosmetic - CITATION.cff exists
    so a paper can cite a specific version, and it had been quietly citing the wrong one.
    """

    match = re.search(r"^version\s*:\s*[\"']([^\"']+)[\"']", _read(CITATION), re.M)
    if not match:
        raise SystemExit("[!] no version key found in %s" % CITATION)
    return match.group(1)


def settings_gen_version():

View on GitHub (pinned to 77cfb06d76)