Skip to content

Fixed simulate diff mode aborting on repeated unversioned package installs - #6424

Open
djbclark wants to merge 1 commit into
cfengine:masterfrom
djbclark:fix/simulate-pkg-unversioned-install-assert
Open

djbclark wants to merge 1 commit into
cfengine:masterfrom
djbclark:fix/simulate-pkg-unversioned-install-assert

Conversation

@djbclark

Copy link
Copy Markdown
Contributor

--simulate=diff aborted an assert-enabled cf-agent when the same package was recorded as installed twice without a version: DiffPkgOperations() passed the two empty versions to PkgVersionIsGreater(), which asserts both non-empty. ManifestPkgOperations() already guards that comparison; the diff branch now uses the same guard and keeps the same record (versioned over unversioned, otherwise the higher version, otherwise the first). Release builds compile the assert out and already picked the same record, so nothing changes for them. Two unit tests; the first aborts on the unguarded code (library built with asserts on):

$ tests/unit/simulate_mode_test      # without the fix
test_diff_repeated_unversioned_install: Starting test
simulate_mode_test: simulate_mode.c:676: PkgVersionIsGreater: Assertion `!NULL_OR_EMPTY(ver1) && !NULL_OR_EMPTY(ver2)' failed.
Aborted
$ tests/unit/simulate_mode_test      # with the fix
test_diff_repeated_unversioned_install: Test completed successfully.
test_diff_unversioned_then_versioned_install: Test completed successfully.
All 7 tests passed

Ubuntu 24.04 (--enable-debug): make -C tests/unit check → All 76 tests passed; tests/acceptance/29_simulate_mode/ as root → 4 of 4 Pass. Fork CI: djbclark#45

AI-assisted. I can't vouch for the C syntax beyond a basic level, but I did look at the logic and it seemed sound.

🤖 Generated with Claude Code

…talls

DiffPkgOperations() compared the versions of two recorded installations
of the same package without checking that both were set, which
PkgVersionIsGreater() asserts. The diff report now keeps the record the
way the manifest report does: a versioned record over an unversioned
one, otherwise the higher version, otherwise the first one recorded.

Ticket: none
Changelog: Title
Signed-off-by: Daniel JB Clark <djbclark@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant