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

[bug]: "Exception: cryptography>=3.1 is required for AES algorithm" #120

Open
ga-it opened this issue Dec 26, 2024 · 2 comments
Open

[bug]: "Exception: cryptography>=3.1 is required for AES algorithm" #120

ga-it opened this issue Dec 26, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ga-it
Copy link

ga-it commented Dec 26, 2024

PDF imports fail with "Exception: cryptography>=3.1 is required for AES algorithm"

processing source: files__default: 7999370
Traceback (most recent call last):
File "/app/context_chat_backend/chain/ingest/doc_loader.py", line 133, in decode_source
result = _loader_mapmimetype
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/context_chat_backend/chain/ingest/doc_loader.py", line 43, in _load_pdf
return '\n\n'.join([page.extract_text().strip() for page in pdf_reader.pages])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/app/context_chat_backend/chain/ingest/doc_loader.py", line 43, in
return '\n\n'.join([page.extract_text().strip() for page in pdf_reader.pages])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_page.py", line 2595, in iter
for i in range(len(self)):
^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_page.py", line 2520, in len
return self.length_function()
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_doc_common.py", line 351, in get_num_pages
return self.root_object["/Pages"]["/Count"] # type: ignore
~~~~~~~~~~~~~~~~^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/generic/_data_structures.py", line 477, in getitem
return dict.getitem(self, key).get_object()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/generic/_base.py", line 371, in get_object
return self.pdf.get_object(self)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_reader.py", line 418, in get_object
retval = self._get_object_from_stream(indirect_reference) # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_reader.py", line 354, in _get_object_from_stream
obj_stm: EncodedStreamObject = IndirectObject(stmnum, 0, self).get_object() # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/generic/_base.py", line 371, in get_object
return self.pdf.get_object(self)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_reader.py", line 488, in get_object
retval = self._encryption.decrypt_object(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_encryption.py", line 863, in decrypt_object
return cf.decrypt_object(obj)
^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_encryption.py", line 99, in decrypt_object
obj._data = self.stm_crypt.decrypt(obj._data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dist-packages/pypdf/_crypt_providers/_fallback.py", line 69, in decrypt
raise DependencyError(_DEPENDENCY_ERROR_STR)
pypdf.errors.DependencyError: cryptography>=3.1 is required for AES algorithm
ERROR:root:Error decoding source file (files__default: 7999370)

[Nextcloud Hub 9] (30.0.1)
Nextcloud Assistant Context Chat 4.0.1
context_chat_backend 4.0.1
Remote AppAPI server

@ga-it ga-it added the bug Something isn't working label Dec 26, 2024
@kyteinsky
Copy link
Contributor

hello, thanks for trying it out again!
Is 7999370 file id a password protected pdf? If yes, we don't support that and probably won't in the future too.

@DaphneMuller
Copy link

maybe drop a line in the AI documentation about password protected pdf's not supported :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants