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

crash when encountering a broken reference #160

Open
br-olf opened this issue Mar 10, 2024 · 1 comment
Open

crash when encountering a broken reference #160

br-olf opened this issue Mar 10, 2024 · 1 comment

Comments

@br-olf
Copy link
Contributor

br-olf commented Mar 10, 2024

Hi, recently I played around a bit in my database and triggered this strange error:

Process DmenuRunner-2:
Traceback (most recent call last):
  File "/usr/lib/python3.11/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/home/olaf/.local/python-venv/lib/python3.11/site-packages/keepmenu/keepmenu.py", line 333, in run
    self.dmenu_run(self.server.totp_flag.is_set())
  File "/home/olaf/.local/python-venv/lib/python3.11/site-packages/keepmenu/keepmenu.py", line 400, in dmenu_run
    sel = view_all_entries(list(options), filtered_entries, self.database.dbase)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/olaf/.local/python-venv/lib/python3.11/site-packages/keepmenu/view.py", line 28, in view_all_entries
    i.deref('username'),
    ^^^^^^^^^^^^^^^^^^^
  File "/home/olaf/.local/python-venv/lib/python3.11/site-packages/pykeepass/entry.py", line 137, in deref
    return self._kp.deref(getattr(self, attribute))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/olaf/.local/python-venv/lib/python3.11/site-packages/pykeepass/pykeepass.py", line 681, in deref
    value = value.replace(ref, getattr(ref_entry, wanted_field))
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'username'

(the line numbers are a bit off due to my debugging attempts)

I figured out, this occurs when there is a broken reference to another entry. Something like {REF:U@I:XXXXXXXXXXXXXXXX} in the user field where theXXXXXXXXXXXXXXXX is an invalid reference ID. I could not find a way to filter this somehow elegant so I hope you can fix it with this information. I think this is a bug in pykeepass and will report it there as well.

@firecat53
Copy link
Owner

It seems like when your fix gets merged that the existing code i.deref('title') or "") should handle the issue. I may have to add the or "" to other deref calls.

That being said, I'll have to look further if there's a clean way to handle that error for older versions of pykeepass. Thanks for the report!

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

2 participants