[Bug]: gitfs with pygit2 fails to initialize
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
What happened?
With a basic gitfs config that uses pygit2 1.20.0 and salt 3008.2, salt-master fails to start with a TypeError.
git_provider: pygit2
gitfs_remotes:
- git@github.com:myproj/salt.git:
- [..]
causes salt-master to fail on startup
# salt-master --log-level debug
[...]
"The installed version of pygit2 (%s) does not support "
[...]
[CRITICAL] Exception caught while initializing gitfs remote 'git@github.com:myproj/salt.git': expected str, bytes, or bytearray not <class 'NoneType'>
Traceback (most recent call last):
File "/opt/saltstack/salt/lib/python3.14/site-packages/salt/utils/gitfs.py", line 1805, in __init__
self.new = self.init_remote()
~~~~~~~~~~~~~~~~^^
File "/opt/saltstack/salt/lib/python3.14/site-packages/salt/utils/gitfs.py", line 2094, in init_remote
self.gitdir = salt.utils.path.join(self.repo.workdir, ".git")
~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/saltstack/salt/lib/python3.14/site-packages/salt/utils/path.py", line 269, in join
parts = [salt.utils.stringutils.to_str(part) for part in parts]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "/opt/saltstack/salt/lib/python3.14/site-packages/salt/utils/stringutils.py", line 90, in to_str
raise TypeError(f"expected str, bytes, or bytearray not {type(s)}")
TypeError: expected str, bytes, or bytearray not <class 'NoneType'>
[...]
Adding a debug log to utils/gitfs.py at line 2094, we see that self.repo.workdir is None.
log.debug(f"Constructing path to .git repo using {self.repo.workdir}")
self.gitdir = salt.utils.path.join(self.repo.workdir, ".git")
gives us [DEBUG ] Constructing path to .git repo using None
Changing gitfs_provider to gitcli allow salt-master to start correctly.
It looks like there might be something that does not get initialized correctly on the fallback path when pygit2 fails.
Type of salt install
Official rpm
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)
rockylinux-9
salt --versions-report output
Salt Version:
Salt: 3008.2
Python Version:
Python: 3.14.6 (main, Jun 11 2026, 02:19:05) [GCC 11.2.0]
Dependency Versions:
cffi: 2.0.0
cherrypy: 18.10.0
cryptography: 48.0.0
dateutil: 2.9.0.post0
docker-py: Not Installed
gitdb: 4.0.12
gitpython: 3.1.50
Jinja2: 3.1.6
libgit2: 1.9.7
looseversion: 1.3.0
M2Crypto: Not Installed
Mako: Not Installed
msgpack: 1.1.2
msgpack-pure: Not Installed
mysql-python: Not Installed
packaging: 24.0
pycparser: 3.00
pycrypto: Not Installed
pycryptodome: 3.23.0
pygit2: 1.20.1
python-gnupg: 0.5.6
PyYAML: 6.0.3
PyZMQ: 27.1.0
relenv: 0.22.14
smmap: 5.0.2
timelib: 0.3.0
Tornado: 6.5.7
ZMQ: 4.3.5
Salt Package Information:
Package Type: onedir
System Versions:
dist: rocky 9.8 Blue Onyx
locale: utf-8
machine: x86_64
release: 5.14.0-687.10.1.el9_8.0.1.x86_64
system: Linux
version: Rocky Linux 9.8 Blue Onyx
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in salt/utils/gitfs.py at GitFS.init and init_remote(), especially the line constructing .git from self.repo.workdir. Reproduce the shown pygit2 configuration with salt-master and trace the fallback path; done means the pygit2 setup no longer fails with a None workdir and salt-master starts successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- git, python
- Domain
- infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100