-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Fix kernelpkg.latest_available() regex for Debian Bullseye/Ubuntu Noble (#68204) #68288
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
aiodinlabs01
wants to merge
2
commits into
saltstack:master
Choose a base branch
from
AIOdinLabs:fix-kernelpkg-regex-issue-68204
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix kernelpkg.latest_available() regex for Debian Bullseye/Ubuntu Noble (#68204) #68288
aiodinlabs01
wants to merge
2
commits into
saltstack:master
from
AIOdinLabs:fix-kernelpkg-regex-issue-68204
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
twangboy
reviewed
Aug 26, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please provide a changelog
…le (saltstack#68204) This fix addresses a critical bug in Salt's kernelpkg_linux_apt module where the latest_available() function would crash with AttributeError on modern Debian and Ubuntu systems due to a regex pattern that couldn't parse current package version formats. ## Problem The kernelpkg.latest_available() function used a regex pattern that expected version formats like '6.1.0.147' but modern Debian/Ubuntu package managers return formats like: - Debian 12: '6.1.147-1' - Ubuntu 24.04: '6.8.0-45-generic' - Debian 11: '5.10.0-18-amd64' The original regex ^(\d+\.\d+\.\d+)\.(\d+) failed to match these formats, causing: AttributeError: 'NoneType' object has no attribute 'group' This made kernelpkg.latest_available() completely unusable on: - Debian 11 (Bullseye) - Debian 12 (Bookworm) - Ubuntu 22.04 (Jammy) - Ubuntu 23.04 (Lunar) - Ubuntu 24.04 (Noble) ## Root Cause In salt/modules/kernelpkg_linux_apt.py line 86, the regex pattern was too restrictive: ## Solution Updated the regex pattern to handle modern Debian/Ubuntu version formats: ### Key Improvements: 1. **Broader compatibility**: Handles both dash and dot separators 2. **Fallback mechanism**: Returns latest_installed() if regex fails completely 3. **Format detection**: Distinguishes between simple Debian and complex Ubuntu formats 4. **Graceful degradation**: Never crashes, always returns a usable result ## Testing Added comprehensive test suite with 16 test cases covering: - All problematic version formats from the issue - Debian 11, 12 (Bookworm) formats - Ubuntu 22.04, 23.04, 24.04 (Noble) formats - Security updates, backports, complex formats - Fallback behavior for malformed versions - Regression prevention for edge cases ### Test Results: ## Impact - ✅ **Fixes kernelpkg.latest_available() on all modern Debian/Ubuntu systems** - ✅ **Maintains 100% backward compatibility** - ✅ **No breaking changes** to existing functionality - ✅ **Comprehensive test coverage** prevents future regressions - ✅ **Graceful fallback** handling for unexpected version formats ## Version Compatibility Matrix | Distribution | Version | Before Fix | After Fix | |--------------|---------|------------|-----------| | Debian 11 (Bullseye) | 5.10.0-18-amd64 | ❌ Crash | ✅ Works | | Debian 12 (Bookworm) | 6.1.147-1 | ❌ Crash | ✅ Works | | Ubuntu 22.04 (Jammy) | 5.15.0-91-generic | ❌ Crash | ✅ Works | | Ubuntu 23.04 (Lunar) | 6.2.0-37-generic | ❌ Crash | ✅ Works | | Ubuntu 24.04 (Noble) | 6.8.0-45-generic | ❌ Crash | ✅ Works | | Security Updates | 6.1.147-1+deb12u1 | ❌ Crash | ✅ Works | | Backports | 6.1.147-1~bpo11+1 | ❌ Crash | ✅ Works | Fixes saltstack#68204
45051ed
to
70c1e98
Compare
twangboy
approved these changes
Aug 29, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fix addresses a critical bug in Salt's kernelpkg_linux_apt module where the latest_available() function would crash with AttributeError on modern Debian and Ubuntu systems due to a regex pattern that couldn't parse current package version formats.
Problem
The kernelpkg.latest_available() function used a regex pattern that expected version formats like '6.1.0.147' but modern Debian/Ubuntu package managers return formats like:
The original regex ^(\d+.\d+.\d+).(\d+) failed to match these formats, causing:
AttributeError: 'NoneType' object has no attribute 'group'
This made kernelpkg.latest_available() completely unusable on:
Root Cause
In salt/modules/kernelpkg_linux_apt.py line 86, the regex pattern was too restrictive:
Solution
Updated the regex pattern to handle modern Debian/Ubuntu version formats:
Key Improvements:
Testing
Added comprehensive test suite with 16 test cases covering:
Test Results:
Impact
Version Compatibility Matrix
| Distribution | Version | Before Fix | After Fix | |--------------|---------|------------|-----------| | Debian 11 (Bullseye) | 5.10.0-18-amd64 | ❌ Crash | ✅ Works | | Debian 12 (Bookworm) | 6.1.147-1 | ❌ Crash | ✅ Works | | Ubuntu 22.04 (Jammy) | 5.15.0-91-generic | ❌ Crash | ✅ Works | | Ubuntu 23.04 (Lunar) | 6.2.0-37-generic | ❌ Crash | ✅ Works | | Ubuntu 24.04 (Noble) | 6.8.0-45-generic | ❌ Crash | ✅ Works | | Security Updates | 6.1.147-1+deb12u1 | ❌ Crash | ✅ Works | | Backports | 6.1.147-1~bpo11+1 | ❌ Crash | ✅ Works |
Fixes #68204
What does this PR do?
What issues does this PR fix or reference?
Fixes
Previous Behavior
Remove this section if not relevant
New Behavior
Remove this section if not relevant
Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
Commits signed with GPG?
Yes/No