saltstack / saltstack/salt

[Bug]: cached Salt-SSH thin archive ignores extension and thin_extra_mods changes

Open
#70,287 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

What happened?

salt.utils.thin.gen_thin() rebuilds a cached archive only when the Salt version or the Python major version changed. Everything else that decides its contents is ignored, so after the archive exists in <cachedir>/thin/thin.tgz:

  • installing, upgrading or removing a Salt extension does not change what is shipped;
  • setting or changing thin_extra_mods does not change what is shipped.

Both keep silently using the stale archive until --regen-thin is passed. This is easy to hit right after diagnosing a missing module, because the fix (installing an extension, or adding its pure-Python dependency to thin_extra_mods) appears to do nothing.

Separately, thin_extra_mods cannot name a module inside a namespace package, which is what every Salt extension is:

  File "salt/utils/thin.py", line 485, in get_tops
    moddir, modname = os.path.split(import(mod).file)
TypeError: expected str, bytes or os.PathLike object, not NoneType

__import__("saltext.mysql") returns the saltext namespace package, whose __file__ is None. This is the "different error" mentioned in #70284. It only surfaces when the archive is actually regenerated, since the cache check above returns before get_tops() runs.

What did you expect to happen?

A cached thin archive is rebuilt when its configured contents change, and thin_extra_mods
accepts a module inside a namespace package.

Steps to reproduce the behavior

With saltext.mysql and pymysql importable:

from salt.utils.thin import gen_thin

gen_thin("/tmp/cache")                         # archive built
gen_thin("/tmp/cache", extra_mods="pymysql")   # same archive, pymysql not packed
$ tar tf /tmp/cache/thin/thin.tgz | grep -c py3/pymysql/
0

And, on a cache directory where the archive has to be generated:

gen_thin("/tmp/cache2", extra_mods="saltext.mysql", overwrite=True)  # TypeError
Versions

Reproduced on master (691bf09e3b) and on 3008.2.

Type of salt install

pip (pypi)

Major version

3008.x

What supported OS are you seeing the problem on? Can select multiple. (If bug appears on an unsupported OS, please open a GitHub Discussion instead)

macos-15

salt --versions-report output
Salt Version:
          Salt: 3008.2

Python Version:
        Python: 3.12.11 (main, Jun  3 2025, 15:41:47) [Clang 17.0.0 (clang-1700.0.13.3)]

Dependency Versions:
          cffi: 2.1.1
      cherrypy: 18.10.0
  cryptography: 50.0.1
      dateutil: 2.9.0.post0
     docker-py: Not Installed
         gitdb: 4.0.12
     gitpython: 3.1.62
        Jinja2: 3.1.6
       libgit2: Not Installed
  looseversion: 1.3.0
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.2.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 24.0
     pycparser: 3.00
      pycrypto: Not Installed
  pycryptodome: 3.23.0
        pygit2: Not Installed
  python-gnupg: 0.5.6
        PyYAML: 6.0.3
         PyZMQ: 27.2.0
        relenv: Not Installed
         smmap: 5.0.3
       timelib: 0.3.0
       Tornado: 6.5.10
           ZMQ: 4.3.5

Salt Extensions:
 saltext.mysql: 1.1.0

Salt Package Information:
  Package Type: Not Installed

System Versions:
          dist: darwin 25.6.0
        locale: utf-8
       machine: arm64
       release: 25.6.0
        system: Darwin
       version: 26.6.2 arm64

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

Start in salt/utils/thin.py, tracing gen_thin() and get_tops(), then reproduce the two examples with and without an existing cache. Check the surrounding thin-archive logic and related tests, if present. Done means configured extensions and thin_extra_mods cause cached contents to refresh, and a module inside a namespace package can be accepted without the shown TypeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.