stamparm/maltrail · error · SystemExit
[!] no [package] table found in
Error message
[!] no [package] table found in %s
What it means
cargo_version() in check_version.py parses Cargo.toml as text, isolating the [package] table with the regex ^\[package\]\s*$(.*?)(?=^\[|\Z) so that dependency tables like [dependencies] never contribute a version. If no [package] table header exists in the file, it raises SystemExit with this message — the manifest lacks the mandatory package section Cargo itself requires.
Solutions
- Add a [package] section to Cargo.toml with name, version, and edition fields if the crate is a real package.
- If Cargo.toml is a virtual workspace root, point the CARGO constant in check_version.py at a member crate's Cargo.toml that has [package].
- Check git history (git log -p Cargo.toml) to find and restore a [package] section lost in a merge or edit.
- Verify the [package] header is not commented out and starts the line exactly as [package].
Example fix
# before (Cargo.toml) [workspace] members = ["sensor"] # after [package] name = "sensor" version = "3.0.0" edition = "2021"
Defensive patterns
Strategy: validation
Validate before calling
import re
text = open("Cargo.toml").read()
assert re.search(r'^\[package\]\s*$', text, re.M), \
"Cargo.toml must contain a [package] table before running check_version" Prevention
- Never delete the [package] section; for workspaces, keep per-crate manifests intact and check member manifests, not virtual workspace roots.
- Run cargo verify-project or cargo metadata in CI before the version-consistency check to catch broken manifests early.
- Review merges touching Cargo.toml carefully; a dropped [package] header fails both cargo and this checker.
- Keep the CARGO path constant in check_version.py in sync with repo restructurings.
When it happens
Trigger: Cargo.toml does not contain a line starting with [package]: the file is empty, was truncated, is actually a different TOML file (wrong path in the CARGO constant), uses a workspace-root manifest that only holds [workspace], or the header is malformed (e.g. [ package ] with inner spaces on the same line pattern the regex doesn't match, or commented out).
Common situations: A workspace root Cargo.toml (virtual manifest) with only [workspace] is checked instead of the member crate's manifest; a bad merge dropped the [package] section; the file path constant became stale after restructuring the repo.
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
- [!] no version key in the [package] table of
- [!] no VERSION assignment in core/settings.py
- [!] cannot bump %r - expected 'major.minor'
- [!] : expected exactly 1 version line, matched Refusing to…
- [!] : expected exactly 1 date-released line, matched
AI-assisted analysis of stamparm/maltrail@77cfb06d76 (2026-09-13).
Data as JSON: /api/errors/298407830ba6c150.
Report an issue: GitHub.
Appendix: source
Thrown at sensor/tools/check_version.py:53
def _read(path):
with open(path, "r") as f:
return f.read()
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)View on GitHub (pinned to 77cfb06d76)