{"record":{"id":"08875070460ee882","repo":"GyulyVGC/sniffnet","slug":"debian-changelog-must-match-the-tagged-cargo-toml-version","errorCode":null,"errorMessage":"debian/changelog must match the tagged Cargo.toml version","messagePattern":"debian/changelog must match the tagged Cargo\\.toml version","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"resources/packaging/linux/deb-source/prepare.py","lineNumber":51,"sourceCode":"        for path in Path(staging).iterdir():\n            shutil.move(str(path), output / path.name)\n    print(f\"Release files: {output}\", flush=True)\n    return output / source.name\n\n\ndef prepare_staged(output):\n    changelog = (DEBIAN / \"changelog\").read_text()\n    match = re.match(r\"sniffnet \\(([^)]+)\\) ([\\w-]+);\", changelog)\n    if not match:\n        raise SystemExit(\"Cannot parse debian/changelog\")\n    version = match[1].rsplit(\"-\", 1)[0]\n    tag = f\"refs/tags/v{version}\"\n    commit = run(\"git\", \"rev-parse\", \"--verify\", f\"{tag}^{{commit}}\",\n                 capture_output=True, text=True).stdout.strip()\n    manifest = tomllib.loads(run(\"git\", \"show\", f\"{commit}:Cargo.toml\",\n                                capture_output=True, text=True).stdout)\n    if manifest[\"package\"][\"version\"] != version:\n        raise SystemExit(\"debian/changelog must match the tagged Cargo.toml version\")\n    source = output / f\"sniffnet-{version}\"\n    archive = output / f\"sniffnet_{version}.orig.tar.gz\"\n    if source.exists() or archive.exists():\n        raise SystemExit(f\"Refusing to overwrite an existing release in {output}; use --output with a fresh directory\")\n    epoch = int(run(\"git\", \"show\", \"-s\", \"--format=%ct\", commit,\n                    capture_output=True, text=True).stdout)\n    output.mkdir(parents=True, exist_ok=True)\n    source.mkdir()\n\n    # Extract only release-tag inputs. A branch with the same name cannot win\n    # ref resolution, and local application edits cannot enter the package.\n    snapshot = run(\"git\", \"archive\", \"--format=tar\", commit,\n                   capture_output=True).stdout\n    run(\"tar\", \"-xf\", \"-\", cwd=source, input=snapshot)\n    # Overlay current Debian packaging after creating the upstream archive.\n    if (source / \"debian\").exists():\n        shutil.rmtree(source / \"debian\")\n    print(f\"Upstream tag: {tag}\\nUpstream commit: {commit}\", flush=True)","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/GyulyVGC/sniffnet/blob/592a62a5ad2fb2e9f8470a6174ab9f18dc86997a/resources/packaging/linux/deb-source/prepare.py#L33-L69","documentation":"prepare_staged() cross-checks the version parsed from debian/changelog against the 'package.version' field of Cargo.toml at the commit the corresponding git tag (v<version>) points to. If the tagged manifest's version differs from the changelog version, the script aborts, because the Debian source package would claim a version that does not match the upstream code it packages.","triggerScenarios":"Running prepare.py when debian/changelog says e.g. 1.3.1 but refs/tags/v1.3.1's Cargo.toml has version '1.3.0' — i.e. the changelog was bumped without tagging a matching release, the tag points at the wrong commit, or Cargo.toml version was edited after tagging.","commonSituations":"Bumping debian/changelog for a release before creating the git tag; tagging a release but forgetting to bump Cargo.toml in the tagged commit; a Debian revision suffix (-1) being handled but the base version diverging from the tag; moving a tag to a different commit after the changelog was written.","solutions":["Make Cargo.toml's package.version in the commit tagged v<version> equal the changelog version, then re-tag (git tag -f vX.Y.Z && git push -f origin vX.Y.Z)","Update debian/changelog to the version that the existing tag actually carries","Verify the tag points at the intended commit: git rev-parse --verify refs/tags/vX.Y.Z^{commit}"],"exampleFix":"// before (Cargo.toml at tag v1.3.1)\nversion = \"1.3.0\"\n# after\nversion = \"1.3.1\"\n# then: git add Cargo.toml && git commit && git tag -f v1.3.1","handlingStrategy":"validation","validationCode":"version = re.search(r\"sniffnet \\(([^)]+)\\)\", changelog_text).group(1).rsplit(\"-\", 1)[0]\ncommit = subprocess.run([\"git\", \"rev-parse\", \"--verify\", f\"refs/tags/v{version}^{{commit}}\"],\n                        capture_output=True, text=True, check=True).stdout.strip()\ncargo_version = tomllib.loads(subprocess.run([\"git\", \"show\", f\"{commit}:Cargo.toml\"],\n                        capture_output=True, text=True, check=True).stdout)[\"package\"][\"version\"]\nif cargo_version != version:\n    raise SystemExit(f\"Tag v{version} has Cargo.toml version {cargo_version}; align before packaging\")","typeGuard":"def versions_are_consistent(changelog_version: str, cargo_version: str) -> bool:\n    return changelog_version == cargo_version","tryCatchPattern":"try:\n    prepare(output)\nexcept SystemExit as e:\n    if \"must match the tagged Cargo.toml version\" in str(e):\n        print(\"Bump Cargo.toml (or the changelog) and re-tag: git tag -f vX.Y.Z\", file=sys.stderr)\n    raise","preventionTips":["Bump Cargo.toml and debian/changelog in the same release commit before tagging","Never move release tags after the changelog entry is written","Add a CI check comparing Cargo.toml version with debian/changelog for each tag","Use a release script that updates both files atomically"],"tags":["versioning","debian","git-tag","consistency-check"],"backgroundTag":"schema-validation-failed","analyzedSha":"592a62a5ad2fb2e9f8470a6174ab9f18dc86997a","analyzedAt":"2026-09-18T11:20:14.290Z","contentChangedAt":"2026-09-18T11:20:14.290Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}