Skip to content

Fix package on Fedora 44 by ignoring unexpected Upgrades DNF5 header - #681

Open
nsballmann wants to merge 3 commits into
OpenVoxProject:mainfrom
nsballmann:fix-fc44-upgrades-header
Open

nsballmann wants to merge 3 commits into
OpenVoxProject:mainfrom
nsballmann:fix-fc44-upgrades-header

Conversation

@nsballmann

@nsballmann nsballmann commented Sep 24, 2026 •

Copy link
Copy Markdown

Short description

Remove the Upgrades header. The update process in Fedora 44 was blocked by this header.
#555 (comment)

The header was introduced 7 months ago.
https://github.com/rpm-software-management/dnf5/blob/main/dnf5/commands/check-upgrade/check-upgrade.cpp#L211

Checklist

I have:

# Strip off all content that contains Obsoleting, Security: or Update
body = str.partition(/^(Obsoleting|Security:|Update)/).first

body = body.gsub(/^Upgrades.*?$/m, '')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body = body.gsub(/^Upgrades.*?$/m, '')
body = body.gsub(/^Upgrades.*?$/m, '')

I would keep the empty newline after the body modifications.

Suggested change
body = body.gsub(/^Upgrades.*?$/m, '')
body.gsub!(/^Upgrades.*?$/m, '')

@OpenVoxProject do you prefer the in-place gsub call?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muald I just learnt that in Ruby RegExp the anchors ^ and $ match in m mode actually at the line boundaries and not at the string boundaries (according to the back of my head this used to be different... in Python). This means, due to the $ anchor the match will definitely anchor at the end of the first line. As we want the whole first line gone, we then probably don't need the non-greedy ?.

But we definitely need the m mode otherwise $ would anchor at the end of the whole body string.

We do leave an empty newline after the substitution.

Alternatively, without m mode, we could also do this:

Suggested change
body = body.gsub(/^Upgrades.*?$/m, '')
# https://regex101.com/r/LiVD53/2/substitution
body.gsub!(/^Upgrades.*\R/, '')

This would remove only the whole first line of the body, if it starts with Upgrades.

@bastelfreak what do you think?

@nsballmann

Copy link
Copy Markdown
Author

@muald I would probably go with the suggestion from #613 (comment) as this IMHO is the cleanest way of removing the line.

@nsballmann

nsballmann commented Sep 24, 2026 •

Copy link
Copy Markdown
Author

To replace #613 as @muald will change roles in the near future.

@muald muald mentioned this pull request Sep 24, 2026
4 tasks
@nsballmann
nsballmann force-pushed the fix-fc44-upgrades-header branch from cf15f71 to 3b06316 Compare September 24, 2026 13:28
@nsballmann nsballmann changed the title remove Upgrades header Fix package on Fedora 44 by ignoring unexpected Upgrades DNF5 header Sep 24, 2026
@nsballmann

Copy link
Copy Markdown
Author

@binford2k or @rwaffen is there something to do differently? Adding tests maybe?

Are @muald and I doing this in the correct repository, in the first place?

@nsballmann
nsballmann marked this pull request as ready for review September 24, 2026 13:43
@bastelfreak bastelfreak added the bug Something isn't working label Sep 25, 2026
@bastelfreak

bastelfreak commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

@nsballmann yes this is the right repo. Could you add some tests, with fixtures, to https://github.com/OpenVoxProject/openvox/blob/main/spec/unit/provider/package/yum_spec.rb ? Best would be some Fedora 43 and 44 fixtures so we can ensure that we don't break older versions

@nsballmann

nsballmann commented Sep 25, 2026 •

Copy link
Copy Markdown
Author

@bastelfreak yes, I can try. Though it's the first time for me doing this. Can you please point me to an example from which I can derive this?

Do you want this to be scoped to the specific DNF5 version that introduced this or is it okay to scope this on the OS release level?

@nsballmann
nsballmann force-pushed the fix-fc44-upgrades-header branch 2 times, most recently from ac05c63 to 3aceccc Compare September 25, 2026 12:50
@nsballmann

Copy link
Copy Markdown
Author

@bastelfreak I think I added some tests. But it's unclear to me how to scope them to specific major distro releases.

@@ -133,7 +133,7 @@ def self.check_updates(disablerepo, enablerepo, disableexcludes)
def self.parse_updates(str)
# Strip off all content that contains Obsoleting, Security: or Update
body = str.partition(/^(Obsoleting|Security:|Update)/).first

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it work to add Upgrades to this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bastelfreak sorry for not responding that long. It was really a lengthy... Cyber Awareness October...

I'm no Ruby expert, but no I don't think this would work. In my understanding .partition() splits the whole content into partitions. I think the .first would then give the first element of the resulting array and due to the new header this would by an empty partition before the partition we're interested in, due to the new (unexpected) dividing element.

I think that's the reason @muald chose to modify body.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either way, .partition is returning some empty strings. Have you considered just filtering them out with .reject!(&:empty?)?

@stondo

stondo commented Oct 27, 2026

Copy link
Copy Markdown

I tested this on Fedora 44 (dnf5 5.4.6, openvox-agent 8.31.1-1.fc44).

With curl downgraded, dnf check-upgrade prints:

Updating and loading repositories:
Repositories loaded.
Upgrades
curl.x86_64 8.18.0-14.fc44 updates

Without this patch, puppet resource package curl ensure=latest reports ensure => '8.18.0-4.fc44' and changes nothing. With the patch applied to the installed yum.rb, the same command runs ensure changed '8.18.0-4.fc44' to '0:8.18.0-14.fc44'.

On 5.4.6 the header is just Upgrades. The fixture in this PR has the longer Upgrades (available for reinstall, available for upgrade) form, and the pattern covers both.

On adding Upgrades to the partition regex: partition(...).first is the text before the first match, so the package list that follows the header is discarded:

s = "Upgrades\ncurl.x86_64 8.18.0-14.fc44 updates\n"
s.partition(/^(Obsoleting|Security:|Update|Upgrades)/).first  # => ""

The existing entries mark sections that come after the update list. DNF5 prints Upgrades before it.

One note on the pattern as written: it is correct, but only because of the lazy ?. In Ruby ^ and $ always match at line boundaries, and /m makes . match newlines, so /^Upgrades.*$/m without the ? would remove everything to the end of the output. /^Upgrades.*$/ without /m behaves like the current pattern and doesn't depend on the ?.

@stondo

stondo commented Oct 27, 2026

Copy link
Copy Markdown

@nsballmann a suggestion for the tests, in case it helps with the review:

  1. Add the bare-header form that dnf5 5.4.6 prints on Fedora 44 (captured on a Fedora 44 machine), spec/fixtures/unit/provider/package/yum/yum-check-update-with-bare-updates-header.txt:

    Updating and loading repositories:
    Repositories loaded.
    Upgrades
    curl.x86_64 8.18.0-14.fc44 updates
    
    context "with bare updates header (dnf5 5.4)" do
      let(:check_update) { File.read(my_fixture("yum-check-update-with-bare-updates-header.txt")) }
      let(:output) { described_class.parse_updates(check_update) }
    
      it "parses only the package entries" do
        expect(output.keys).to contain_exactly('curl', 'curl.x86_64')
        expect(output['curl']).to eq([{:name => 'curl', :epoch => '0', :version => '8.18.0', :release => '14.fc44', :arch => 'x86_64'}])
      end
    end
  2. The two expect(output).not_to include("Upgrades (available for reinstall, available for upgrade)") examples pass with and without the fix, because parse_updates only returns package names as keys. expect(output.keys).to contain_exactly('curl', 'curl.x86_64') checks the same thing and fails when the header leaks into the parsing.

With the fix reverted, the "with updates header" example and the bare-header example above fail, and with the fix all pass.

On scoping the tests to distro releases: I don't think it's needed. parse_updates only sees the check-update text, so one fixture per output format (no header, long header, bare header) covers Fedora 43 and 44 without tying the tests to OS facts.

@nsballmann

Copy link
Copy Markdown
Author

One note on the pattern as written: it is correct, but only because of the lazy ?. In Ruby ^ and $ always match at line boundaries, and /m makes . match newlines, so /^Upgrades.*$/m without the ? would remove everything to the end of the output. /^Upgrades.*$/ without /m behaves like the current pattern and doesn't depend on the ?.

@stondo yes, I'm aware. I just wanted to present multiple options to find one that will be generally understood in the project. Regex are usually a source for confusion, therefore I try to find a Regex which does what we require but is readable enough to be acceptable.

@nsballmann

Copy link
Copy Markdown
Author

@nsballmann a suggestion for the tests, in case it helps with the review:

  1. Add the bare-header form that dnf5 5.4.6 prints on Fedora 44 (captured on a Fedora 44 machine), spec/fixtures/unit/provider/package/yum/yum-check-update-with-bare-updates-header.txt:

    Updating and loading repositories:
    Repositories loaded.
    Upgrades
    curl.x86_64 8.18.0-14.fc44 updates
    
    context "with bare updates header (dnf5 5.4)" do
      let(:check_update) { File.read(my_fixture("yum-check-update-with-bare-updates-header.txt")) }
      let(:output) { described_class.parse_updates(check_update) }
    
      it "parses only the package entries" do
        expect(output.keys).to contain_exactly('curl', 'curl.x86_64')
        expect(output['curl']).to eq([{:name => 'curl', :epoch => '0', :version => '8.18.0', :release => '14.fc44', :arch => 'x86_64'}])
      end
    end
  2. The two expect(output).not_to include("Upgrades (available for reinstall, available for upgrade)") examples pass with and without the fix, because parse_updates only returns package names as keys. expect(output.keys).to contain_exactly('curl', 'curl.x86_64') checks the same thing and fails when the header leaks into the parsing.

With the fix reverted, the "with updates header" example and the bare-header example above fail, and with the fix all pass.

On scoping the tests to distro releases: I don't think it's needed. parse_updates only sees the check-update text, so one fixture per output format (no header, long header, bare header) covers Fedora 43 and 44 without tying the tests to OS facts.

@stondo seems like I overlooked that variant. Thank you. I would add you as author in a separate commit. Are you okay with that?

muald and others added 2 commits November 16, 2026 11:25
Signed-off-by: Markus Urbanczyk <markus.urbanczyk@evosoft.com>
Signed-off-by: Nils Ballmann <nils.ballmann@siemens.com>
Signed-off-by: Nils Ballmann <nils.ballmann@siemens.com>
@nsballmann
nsballmann force-pushed the fix-fc44-upgrades-header branch from 3aceccc to 5f6aef5 Compare November 16, 2026 10:27
Co-authored-by: Stefano Tondo <stondo@gmail.com>
Signed-off-by: Nils Ballmann <nils.ballmann@siemens.com>
@nsballmann

Copy link
Copy Markdown
Author

@stondo seems like I overlooked that variant. Thank you. I would add you as author in a separate commit. Are you okay with that?

@stondo I now did with Co-authored-by:, okay?

@stondo

stondo commented Nov 16, 2026

Copy link
Copy Markdown

@nsballmann yes, that's fine with me, thanks. The new test is the same one I ran on Fedora 44.

One small point, if you want it: the two not_to include("Upgrades (available for reinstall, available for upgrade)") checks still pass with the fix reverted, because parse_updates only returns package names as keys. If you change them to expect(output.keys).to contain_exactly(...), as in the bare-header test, they also catch a regression.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants