'_pygit2.Blob' object has no attribute 'oid' with 1.15.1
I use pygit2 with Salt Stack (3007.1 from pypi.org). I upgraded pygit from 1.12.1 to 1.15.1 and got errors in /var/log/salt/master. Downgraded pygit2 to 1.14.1 and now it works.
2024-09-06 14:46:44,464 [salt.master :279 ][ERROR ][26484] Uncaught exception while updating gitfs fileserver cache
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/salt/master.py", line 532, in _do_update
update_func(*args)
File "/usr/local/lib/python3.11/site-packages/salt/loader/lazy.py", line 160, in __call__
ret = self.loader.run(run_func, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/salt/loader/lazy.py", line 1269, in run
return self._last_context.run(self._run_as, _func_or_method, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/salt/loader/lazy.py", line 1284, in _run_as
return _func_or_method(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/salt/fileserver/gitfs.py", line 138, in update
_gitfs().update(remotes)
File "/usr/local/lib/python3.11/site-packages/salt/utils/gitfs.py", line 2798, in update
salt.fileserver.reap_fileserver_cache_dir(
File "/usr/local/lib/python3.11/site-packages/salt/fileserver/__init__.py", line 273, in reap_fileserver_cache_dir
ret = find_func(filename, saltenv=saltenv)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/salt/utils/gitfs.py", line 3157, in find_file
blob, blob_hexsha, blob_mode = repo.find_file(repo_path, tgt_env)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/salt/utils/gitfs.py", line 2176, in find_file
blob = self.repo[entry.oid]
^^^^^^^^^
AttributeError: '_pygit2.Blob' object has no attribute 'oid'
I have a similar problem with the git filesystem in fsspec and AttributeError: '_pygit2.Blob' object has no attribute 'hex'. Shouldn't these breaking changes in 1.15 have warranted incrementing the major version?
13 days later, this hit me for FreshPorts - searching the issues for OID, I found #1292 which states:
Oid.hex is among the deprecated features that were [removed in 1.15.0](https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md). You can use str(oid) instead.
Clicking on that link, I found this reference which has a list of Breaking changes. Within that list is Remove deprecated object.oid, use object.id
I was also affected by Remove deprecated object.hex, use str(object.id)
My code is fixed. Thanks for this issue.