Skip to content
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

'_pygit2.Blob' object has no attribute 'oid' with 1.15.1 #1316

Open
silviumc opened this issue Sep 6, 2024 · 2 comments
Open

'_pygit2.Blob' object has no attribute 'oid' with 1.15.1 #1316

silviumc opened this issue Sep 6, 2024 · 2 comments

Comments

@silviumc
Copy link

silviumc commented Sep 6, 2024

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'
@mxmlnkn
Copy link

mxmlnkn commented Oct 3, 2024

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?

@dlangille
Copy link

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.

dlangille referenced this issue in FreshPorts/git_proc_commit Oct 19, 2024
From https://github.com/libgit2/pygit2/blob/master/CHANGELOG.md#1150-2024-05-18
under Breaking changes:

* Remove deprecated object.hex, use str(object.id)
* Remove deprecated object.oid, use object.id

This code now requires pygit2>=1.15.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants