saltstack / saltstack/salt

[BUG] regex in kernelpkg latest_available() fails on Debian Bullseye / Ubuntu Noble

Open Beginner friendly
#68,204 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
The kernelpkg.latest_available function throws an error on Ubuntu 24.04 / Debian 11
(same as original issue here , looks like there was never an actual resolution)

Attempting to execute it returns:

    The minion function caused an exception: Traceback (most recent call last):
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 2028, in _thread_return
        return_data = minion_instance._execute_job_function(
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/minion.py", line 1987, in _execute_job_function
        return_data = self.executors[fname](opts, data, func, args, kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
        ret = self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
        ret = _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/executors/direct_call.py", line 10, in execute
        return func(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 159, in __call__
        ret = self.loader.run(run_func, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1245, in run
        return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/loader/lazy.py", line 1260, in _run_as
        ret = _func_or_method(*args, **kwargs)
      File "/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/kernelpkg_linux_apt.py", line 87, in latest_available
        return f"{version.group(1)}-{version.group(2)}-{_kernel_type()}"
    AttributeError: 'NoneType' object has no attribute 'group'

Steps to Reproduce the behavior
# salt myubuntu24host kernelpkg.latest_available

Expected behavior
Should return a string and not an error :)

I logged the result variable from here and got the following result paired with the osfinger:

5.15.0.144.141  (Ubuntu-22.04)
6.8.0-64.67  (Ubuntu-24.04)
6.1.140-1-amd64 (Debian-11)

Simply adding a hyphen into the regex via a class seems to have 'fixed' the issue

$ diff -U 1 kernelpkg_linux_apt.py.3006.13 kernelpkg_linux_apt.py
--- kernelpkg_linux_apt.py.3006.13      2025-06-25 19:12:53.000000000 -0600
+++ kernelpkg_linux_apt.py      2025-07-21 15:59:32.457894885 -0600
@@ -85,3 +86,3 @@

-    version = re.match(r"^(\d+\.\d+\.\d+)\.(\d+)", result)
+    version = re.match(r"^(\d+\.\d+\.\d+)[\-\.](\d+)", result)
     return f"{version.group(1)}-{version.group(2)}-{_kernel_type()}"

Versions Report

salt --versions-report (Provided by running salt --versions-report. Please also mention any differences in master/minion versions.)
    Salt Version:
              Salt: 3006.13

    Python Version:
            Python: 3.10.17 (main, Jun  9 2025, 20:41:48) [GCC 11.2.0]

    Dependency Versions:
              cffi: 1.14.6
          cherrypy: unknown
      cryptography: 42.0.5
          dateutil: 2.8.1
         docker-py: Not Installed
             gitdb: Not Installed
         gitpython: Not Installed
            Jinja2: 3.1.6
           libgit2: Not Installed
      looseversion: 1.0.2
          M2Crypto: Not Installed
              Mako: Not Installed
           msgpack: 1.0.2
      msgpack-pure: Not Installed
      mysql-python: Not Installed
         packaging: 22.0
         pycparser: 2.21
          pycrypto: Not Installed
      pycryptodome: 3.19.1
            pygit2: Not Installed
      python-gnupg: 0.4.8
            PyYAML: 6.0.1
             PyZMQ: 23.2.0
            relenv: 0.19.3
             smmap: Not Installed
           timelib: 0.2.4
           Tornado: 4.5.3
               ZMQ: 4.3.4

    System Versions:
              dist: ubuntu 24.04.2 noble
            locale: utf-8
           machine: x86_64
           release: 6.8.0-64-generic
            system: Linux
           version: Ubuntu 24.04.2 noble

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read salt/modules/kernelpkg_linux_apt.py, especially latest_available and the regex applied to the result variable. Reproduce with salt myubuntu24host kernelpkg.latest_available using the Debian 11 or Ubuntu 24.04 kernel formats shown; done means the function returns the expected version string without an exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
operating-systems
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.