Fixed simulate mode reporting both removal and install of the same package - #25
Fixed simulate mode reporting both removal and install of the same package#25djbclark wants to merge 2 commits into
Conversation
33f0d2b to
9ee0d1b
Compare
Upstream submission package (human-in-the-loop)Everything below is ready to paste. Per upstream's restart protocol the submission itself is djbclark's act: 1 bug ticket + 1 PR, smallest possible, with reproduce and before/after output. Preconditions before submitting:
Step 1 — File the Jira ticket (northerntech.atlassian.net, project CFE, type Bug)Summary:
Description:
Step 2 — Stamp the ticket number into the commitcd ~/src/cfengine-core
git checkout fix/simulate-pkg-mapremove
git commit --amend -m "$(git log -1 --format=%B | sed 's/Ticket: None/Ticket: CFE-XXXX/')"
git push --force-with-lease origin fix/simulate-pkg-mapremove(Replace Step 3 — Open the upstream PRFrom https://github.com/djbclark/core/tree/fix/simulate-pkg-mapremove → "Contribute" → PR against Title:
Body:
Notes for the submitter
|
…ckage In DiffPkgOperations() and ManifestPkgOperations(), inserting an install message into the installed/present map set name_arch to NULL because the map took ownership of it as a key. The MapRemove() call that cancels a previous removal message ran after that, so it looked up a NULL key and matched nothing. The cancellation was silently skipped exactly when an install message had been inserted: a package recorded as removed and then installed was reported as both removed and installed. In debug builds a NULL key also fails an assertion in StringHash() once the map outgrows the array-map stage. Moved the cancellation above the code that hands name_arch to the map. Changelog: Title Ticket: CFE-4742 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
9ee0d1b to
5ddb6d9
Compare
|
Submitted upstream 2026-08-22: ticket CFE-4742, PR cfengine/core#6332 (same commit, |
Co-authored-by: Lars Erik Wik <53906608+larsewi@users.noreply.github.com>
Fixes #24.
In
DiffPkgOperations()andManifestPkgOperations(), inserting an install message into the installed/present map setname_archto NULL because the map took ownership of it as a key. TheMapRemove()call that cancels a previous removal message ran after that, so it looked up a NULL key and matched nothing: a package recorded as removed and then installed was reported as both removed and installed. Moved the cancellation above the code that handsname_archto the map.Includes a regression test (
tests/unit/simulate_mode_test.c) feedingr,foo,,+i,foo,1.2.3,records to both functions; it fails on master and passes with the fix.Testing:
libcf-agentbetween runs)./bin/sh= dash): same pass/fail discrimination.AI-assisted, reviewed and verified by me before submitting.
🤖 Generated with Claude Code