We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[BUG] Could not parse docx document
### Description

I can't upload a docx document after updating to the latest release candidate.

### Steps to reproduce

1. Update paperless-ngx to 1.9.0-rc1 (ghcr.io/paperless-ngx/paperless-ngx:beta)
2. Upload a docx-document and an error occurs "_`Error while consuming document khms-immoconsult_20170924_2.docx: Could not parse /tmp/paperless/paperless-upload-iwgwe9h0 with tika server at http://tika:9998: 'PosixPath' object has no attribute 'decode'`_"

### Webserver logs

```bash
2022-09-14 05:45:14,789] [INFO] [paperless.consumer] Consuming khms-immoconsult_20170924_2.docx

[2022-09-14 05:45:14,791] [DEBUG] [paperless.consumer] Detected mime type: application/vnd.openxmlformats-officedocument.wordprocessingml.document

[2022-09-14 05:45:14,795] [DEBUG] [paperless.consumer] Parser: TikaDocumentParser

[2022-09-14 05:45:14,800] [DEBUG] [paperless.consumer] Parsing khms-immoconsult_20170924_2.docx...

[2022-09-14 05:45:14,801] [INFO] [paperless.parsing.tika] Sending /tmp/paperless/paperless-upload-iwgwe9h0 to Tika server

[2022-09-14 05:45:14,802] [DEBUG] [paperless.parsing.tika] Deleting directory /tmp/paperless/paperless-86t5km9q

[2022-09-14 05:45:14,806] [ERROR] [paperless.consumer] Error while consuming document khms-immoconsult_20170924_2.docx: Could not parse /tmp/paperless/paperless-upload-iwgwe9h0 with tika server at http://tika:9998: 'PosixPath' object has no attribute 'decode'

Traceback (most recent call last):

  File "/usr/src/paperless/src/paperless_tika/parsers.py", line 55, in parse

    parsed = parser.from_file(document_path, tika_server)

  File "/usr/local/lib/python3.9/site-packages/tika/parser.py", line 40, in from_file

    output = parse1(service, filename, serverEndpoint, headers=headers, config_path=config_path, requestOptions=requestOptions)

  File "/usr/local/lib/python3.9/site-packages/tika/tika.py", line 327, in parse1

    path, file_type = getRemoteFile(urlOrPath, TikaFilesPath)

  File "/usr/local/lib/python3.9/site-packages/tika/tika.py", line 762, in getRemoteFile

    urlp = urlparse(urlOrPath)

  File "/usr/local/lib/python3.9/urllib/parse.py", line 392, in urlparse

    url, scheme, _coerce_result = _coerce_args(url, scheme)

  File "/usr/local/lib/python3.9/urllib/parse.py", line 128, in _coerce_args

    return _decode_args(args) + (_encode_result,)

  File "/usr/local/lib/python3.9/urllib/parse.py", line 112, in _decode_args

    return tuple(x.decode(encoding, errors) if x else '' for x in args)

  File "/usr/local/lib/python3.9/urllib/parse.py", line 112, in <genexpr>

    return tuple(x.decode(encoding, errors) if x else '' for x in args)

AttributeError: 'PosixPath' object has no attribute 'decode'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):

  File "/usr/src/paperless/src/documents/consumer.py", line 320, in try_consume_file

    document_parser.parse(self.path, mime_type, self.filename)

  File "/usr/src/paperless/src/paperless_tika/parsers.py", line 57, in parse

    raise ParseError(

documents.parsers.ParseError: Could not parse /tmp/paperless/paperless-upload-iwgwe9h0 with tika server at http://tika:9998: 'PosixPath' object has no attribute 'decode'
```


### Paperless-ngx version

1.9.0-rc1

### Host OS

Ubuntu 22.04 LTS

### Installation method

Docker - official image

### Browser

Google Chrome

### Configuration changes

_No response_

### Other

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/paperless_tika/parsers.py`
Content:
```
1 import os
2 
3 import dateutil.parser
4 import requests
5 from django.conf import settings
6 from documents.parsers import DocumentParser
7 from documents.parsers import make_thumbnail_from_pdf
8 from documents.parsers import ParseError
9 from tika import parser
10 
11 
12 class TikaDocumentParser(DocumentParser):
13     """
14     This parser sends documents to a local tika server
15     """
16 
17     logging_name = "paperless.parsing.tika"
18 
19     def get_thumbnail(self, document_path, mime_type, file_name=None):
20         if not self.archive_path:
21             self.archive_path = self.convert_to_pdf(document_path, file_name)
22 
23         return make_thumbnail_from_pdf(
24             self.archive_path,
25             self.tempdir,
26             self.logging_group,
27         )
28 
29     def extract_metadata(self, document_path, mime_type):
30         tika_server = settings.TIKA_ENDPOINT
31         try:
32             parsed = parser.from_file(document_path, tika_server)
33         except Exception as e:
34             self.log(
35                 "warning",
36                 f"Error while fetching document metadata for " f"{document_path}: {e}",
37             )
38             return []
39 
40         return [
41             {
42                 "namespace": "",
43                 "prefix": "",
44                 "key": key,
45                 "value": parsed["metadata"][key],
46             }
47             for key in parsed["metadata"]
48         ]
49 
50     def parse(self, document_path, mime_type, file_name=None):
51         self.log("info", f"Sending {document_path} to Tika server")
52         tika_server = settings.TIKA_ENDPOINT
53 
54         try:
55             parsed = parser.from_file(document_path, tika_server)
56         except Exception as err:
57             raise ParseError(
58                 f"Could not parse {document_path} with tika server at "
59                 f"{tika_server}: {err}",
60             ) from err
61 
62         self.text = parsed["content"].strip()
63 
64         try:
65             self.date = dateutil.parser.isoparse(parsed["metadata"]["Creation-Date"])
66         except Exception as e:
67             self.log(
68                 "warning",
69                 f"Unable to extract date for document " f"{document_path}: {e}",
70             )
71 
72         self.archive_path = self.convert_to_pdf(document_path, file_name)
73 
74     def convert_to_pdf(self, document_path, file_name):
75         pdf_path = os.path.join(self.tempdir, "convert.pdf")
76         gotenberg_server = settings.TIKA_GOTENBERG_ENDPOINT
77         url = gotenberg_server + "/forms/libreoffice/convert"
78 
79         self.log("info", f"Converting {document_path} to PDF as {pdf_path}")
80         with open(document_path, "rb") as document_handle:
81             files = {
82                 "files": (
83                     file_name or os.path.basename(document_path),
84                     document_handle,
85                 ),
86             }
87             headers = {}
88 
89             try:
90                 response = requests.post(url, files=files, headers=headers)
91                 response.raise_for_status()  # ensure we notice bad responses
92             except Exception as err:
93                 raise ParseError(
94                     f"Error while converting document to PDF: {err}",
95                 ) from err
96 
97         with open(pdf_path, "wb") as file:
98             file.write(response.content)
99             file.close()
100 
101         return pdf_path
102
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/paperless_tika/parsers.py b/src/paperless_tika/parsers.py
--- a/src/paperless_tika/parsers.py
+++ b/src/paperless_tika/parsers.py
@@ -1,4 +1,5 @@
 import os
+from pathlib import Path
 
 import dateutil.parser
 import requests
@@ -28,6 +29,11 @@
 
     def extract_metadata(self, document_path, mime_type):
         tika_server = settings.TIKA_ENDPOINT
+
+        # tika does not support a PathLike, only strings
+        # ensure this is a string
+        document_path = str(document_path)
+
         try:
             parsed = parser.from_file(document_path, tika_server)
         except Exception as e:
@@ -47,10 +53,14 @@
             for key in parsed["metadata"]
         ]
 
-    def parse(self, document_path, mime_type, file_name=None):
+    def parse(self, document_path: Path, mime_type, file_name=None):
         self.log("info", f"Sending {document_path} to Tika server")
         tika_server = settings.TIKA_ENDPOINT
 
+        # tika does not support a PathLike, only strings
+        # ensure this is a string
+        document_path = str(document_path)
+
         try:
             parsed = parser.from_file(document_path, tika_server)
         except Exception as err:

{"golden_diff": "diff --git a/src/paperless_tika/parsers.py b/src/paperless_tika/parsers.py\n--- a/src/paperless_tika/parsers.py\n+++ b/src/paperless_tika/parsers.py\n@@ -1,4 +1,5 @@\n import os\n+from pathlib import Path\n \n import dateutil.parser\n import requests\n@@ -28,6 +29,11 @@\n \n     def extract_metadata(self, document_path, mime_type):\n         tika_server = settings.TIKA_ENDPOINT\n+\n+        # tika does not support a PathLike, only strings\n+        # ensure this is a string\n+        document_path = str(document_path)\n+\n         try:\n             parsed = parser.from_file(document_path, tika_server)\n         except Exception as e:\n@@ -47,10 +53,14 @@\n             for key in parsed[\"metadata\"]\n         ]\n \n-    def parse(self, document_path, mime_type, file_name=None):\n+    def parse(self, document_path: Path, mime_type, file_name=None):\n         self.log(\"info\", f\"Sending {document_path} to Tika server\")\n         tika_server = settings.TIKA_ENDPOINT\n \n+        # tika does not support a PathLike, only strings\n+        # ensure this is a string\n+        document_path = str(document_path)\n+\n         try:\n             parsed = parser.from_file(document_path, tika_server)\n         except Exception as err:\n", "issue": "[BUG] Could not parse docx document\n### Description\n\nI can't upload a docx document after updating to the latest release candidate.\n\n### Steps to reproduce\n\n1. Update paperless-ngx to 1.9.0-rc1 (ghcr.io/paperless-ngx/paperless-ngx:beta)\r\n2. Upload a docx-document and an error occurs \"_`Error while consuming document khms-immoconsult_20170924_2.docx: Could not parse /tmp/paperless/paperless-upload-iwgwe9h0 with tika server at http://tika:9998: 'PosixPath' object has no attribute 'decode'`_\"\n\n### Webserver logs\n\n```bash\n2022-09-14 05:45:14,789] [INFO] [paperless.consumer] Consuming khms-immoconsult_20170924_2.docx\r\n\r\n[2022-09-14 05:45:14,791] [DEBUG] [paperless.consumer] Detected mime type: application/vnd.openxmlformats-officedocument.wordprocessingml.document\r\n\r\n[2022-09-14 05:45:14,795] [DEBUG] [paperless.consumer] Parser: TikaDocumentParser\r\n\r\n[2022-09-14 05:45:14,800] [DEBUG] [paperless.consumer] Parsing khms-immoconsult_20170924_2.docx...\r\n\r\n[2022-09-14 05:45:14,801] [INFO] [paperless.parsing.tika] Sending /tmp/paperless/paperless-upload-iwgwe9h0 to Tika server\r\n\r\n[2022-09-14 05:45:14,802] [DEBUG] [paperless.parsing.tika] Deleting directory /tmp/paperless/paperless-86t5km9q\r\n\r\n[2022-09-14 05:45:14,806] [ERROR] [paperless.consumer] Error while consuming document khms-immoconsult_20170924_2.docx: Could not parse /tmp/paperless/paperless-upload-iwgwe9h0 with tika server at http://tika:9998: 'PosixPath' object has no attribute 'decode'\r\n\r\nTraceback (most recent call last):\r\n\r\n  File \"/usr/src/paperless/src/paperless_tika/parsers.py\", line 55, in parse\r\n\r\n    parsed = parser.from_file(document_path, tika_server)\r\n\r\n  File \"/usr/local/lib/python3.9/site-packages/tika/parser.py\", line 40, in from_file\r\n\r\n    output = parse1(service, filename, serverEndpoint, headers=headers, config_path=config_path, requestOptions=requestOptions)\r\n\r\n  File \"/usr/local/lib/python3.9/site-packages/tika/tika.py\", line 327, in parse1\r\n\r\n    path, file_type = getRemoteFile(urlOrPath, TikaFilesPath)\r\n\r\n  File \"/usr/local/lib/python3.9/site-packages/tika/tika.py\", line 762, in getRemoteFile\r\n\r\n    urlp = urlparse(urlOrPath)\r\n\r\n  File \"/usr/local/lib/python3.9/urllib/parse.py\", line 392, in urlparse\r\n\r\n    url, scheme, _coerce_result = _coerce_args(url, scheme)\r\n\r\n  File \"/usr/local/lib/python3.9/urllib/parse.py\", line 128, in _coerce_args\r\n\r\n    return _decode_args(args) + (_encode_result,)\r\n\r\n  File \"/usr/local/lib/python3.9/urllib/parse.py\", line 112, in _decode_args\r\n\r\n    return tuple(x.decode(encoding, errors) if x else '' for x in args)\r\n\r\n  File \"/usr/local/lib/python3.9/urllib/parse.py\", line 112, in <genexpr>\r\n\r\n    return tuple(x.decode(encoding, errors) if x else '' for x in args)\r\n\r\nAttributeError: 'PosixPath' object has no attribute 'decode'\r\n\r\nThe above exception was the direct cause of the following exception:\r\n\r\nTraceback (most recent call last):\r\n\r\n  File \"/usr/src/paperless/src/documents/consumer.py\", line 320, in try_consume_file\r\n\r\n    document_parser.parse(self.path, mime_type, self.filename)\r\n\r\n  File \"/usr/src/paperless/src/paperless_tika/parsers.py\", line 57, in parse\r\n\r\n    raise ParseError(\r\n\r\ndocuments.parsers.ParseError: Could not parse /tmp/paperless/paperless-upload-iwgwe9h0 with tika server at http://tika:9998: 'PosixPath' object has no attribute 'decode'\n```\n\n\n### Paperless-ngx version\n\n1.9.0-rc1\n\n### Host OS\n\nUbuntu 22.04 LTS\n\n### Installation method\n\nDocker - official image\n\n### Browser\n\nGoogle Chrome\n\n### Configuration changes\n\n_No response_\n\n### Other\n\n_No response_\n", "before_files": [{"content": "import os\n\nimport dateutil.parser\nimport requests\nfrom django.conf import settings\nfrom documents.parsers import DocumentParser\nfrom documents.parsers import make_thumbnail_from_pdf\nfrom documents.parsers import ParseError\nfrom tika import parser\n\n\nclass TikaDocumentParser(DocumentParser):\n    \"\"\"\n    This parser sends documents to a local tika server\n    \"\"\"\n\n    logging_name = \"paperless.parsing.tika\"\n\n    def get_thumbnail(self, document_path, mime_type, file_name=None):\n        if not self.archive_path:\n            self.archive_path = self.convert_to_pdf(document_path, file_name)\n\n        return make_thumbnail_from_pdf(\n            self.archive_path,\n            self.tempdir,\n            self.logging_group,\n        )\n\n    def extract_metadata(self, document_path, mime_type):\n        tika_server = settings.TIKA_ENDPOINT\n        try:\n            parsed = parser.from_file(document_path, tika_server)\n        except Exception as e:\n            self.log(\n                \"warning\",\n                f\"Error while fetching document metadata for \" f\"{document_path}: {e}\",\n            )\n            return []\n\n        return [\n            {\n                \"namespace\": \"\",\n                \"prefix\": \"\",\n                \"key\": key,\n                \"value\": parsed[\"metadata\"][key],\n            }\n            for key in parsed[\"metadata\"]\n        ]\n\n    def parse(self, document_path, mime_type, file_name=None):\n        self.log(\"info\", f\"Sending {document_path} to Tika server\")\n        tika_server = settings.TIKA_ENDPOINT\n\n        try:\n            parsed = parser.from_file(document_path, tika_server)\n        except Exception as err:\n            raise ParseError(\n                f\"Could not parse {document_path} with tika server at \"\n                f\"{tika_server}: {err}\",\n            ) from err\n\n        self.text = parsed[\"content\"].strip()\n\n        try:\n            self.date = dateutil.parser.isoparse(parsed[\"metadata\"][\"Creation-Date\"])\n        except Exception as e:\n            self.log(\n                \"warning\",\n                f\"Unable to extract date for document \" f\"{document_path}: {e}\",\n            )\n\n        self.archive_path = self.convert_to_pdf(document_path, file_name)\n\n    def convert_to_pdf(self, document_path, file_name):\n        pdf_path = os.path.join(self.tempdir, \"convert.pdf\")\n        gotenberg_server = settings.TIKA_GOTENBERG_ENDPOINT\n        url = gotenberg_server + \"/forms/libreoffice/convert\"\n\n        self.log(\"info\", f\"Converting {document_path} to PDF as {pdf_path}\")\n        with open(document_path, \"rb\") as document_handle:\n            files = {\n                \"files\": (\n                    file_name or os.path.basename(document_path),\n                    document_handle,\n                ),\n            }\n            headers = {}\n\n            try:\n                response = requests.post(url, files=files, headers=headers)\n                response.raise_for_status()  # ensure we notice bad responses\n            except Exception as err:\n                raise ParseError(\n                    f\"Error while converting document to PDF: {err}\",\n                ) from err\n\n        with open(pdf_path, \"wb\") as file:\n            file.write(response.content)\n            file.close()\n\n        return pdf_path\n", "path": "src/paperless_tika/parsers.py"}], "after_files": [{"content": "import os\nfrom pathlib import Path\n\nimport dateutil.parser\nimport requests\nfrom django.conf import settings\nfrom documents.parsers import DocumentParser\nfrom documents.parsers import make_thumbnail_from_pdf\nfrom documents.parsers import ParseError\nfrom tika import parser\n\n\nclass TikaDocumentParser(DocumentParser):\n    \"\"\"\n    This parser sends documents to a local tika server\n    \"\"\"\n\n    logging_name = \"paperless.parsing.tika\"\n\n    def get_thumbnail(self, document_path, mime_type, file_name=None):\n        if not self.archive_path:\n            self.archive_path = self.convert_to_pdf(document_path, file_name)\n\n        return make_thumbnail_from_pdf(\n            self.archive_path,\n            self.tempdir,\n            self.logging_group,\n        )\n\n    def extract_metadata(self, document_path, mime_type):\n        tika_server = settings.TIKA_ENDPOINT\n\n        # tika does not support a PathLike, only strings\n        # ensure this is a string\n        document_path = str(document_path)\n\n        try:\n            parsed = parser.from_file(document_path, tika_server)\n        except Exception as e:\n            self.log(\n                \"warning\",\n                f\"Error while fetching document metadata for \" f\"{document_path}: {e}\",\n            )\n            return []\n\n        return [\n            {\n                \"namespace\": \"\",\n                \"prefix\": \"\",\n                \"key\": key,\n                \"value\": parsed[\"metadata\"][key],\n            }\n            for key in parsed[\"metadata\"]\n        ]\n\n    def parse(self, document_path: Path, mime_type, file_name=None):\n        self.log(\"info\", f\"Sending {document_path} to Tika server\")\n        tika_server = settings.TIKA_ENDPOINT\n\n        # tika does not support a PathLike, only strings\n        # ensure this is a string\n        document_path = str(document_path)\n\n        try:\n            parsed = parser.from_file(document_path, tika_server)\n        except Exception as err:\n            raise ParseError(\n                f\"Could not parse {document_path} with tika server at \"\n                f\"{tika_server}: {err}\",\n            ) from err\n\n        self.text = parsed[\"content\"].strip()\n\n        try:\n            self.date = dateutil.parser.isoparse(parsed[\"metadata\"][\"Creation-Date\"])\n        except Exception as e:\n            self.log(\n                \"warning\",\n                f\"Unable to extract date for document \" f\"{document_path}: {e}\",\n            )\n\n        self.archive_path = self.convert_to_pdf(document_path, file_name)\n\n    def convert_to_pdf(self, document_path, file_name):\n        pdf_path = os.path.join(self.tempdir, \"convert.pdf\")\n        gotenberg_server = settings.TIKA_GOTENBERG_ENDPOINT\n        url = gotenberg_server + \"/forms/libreoffice/convert\"\n\n        self.log(\"info\", f\"Converting {document_path} to PDF as {pdf_path}\")\n        with open(document_path, \"rb\") as document_handle:\n            files = {\n                \"files\": (\n                    file_name or os.path.basename(document_path),\n                    document_handle,\n                ),\n            }\n            headers = {}\n\n            try:\n                response = requests.post(url, files=files, headers=headers)\n                response.raise_for_status()  # ensure we notice bad responses\n            except Exception as err:\n                raise ParseError(\n                    f\"Error while converting document to PDF: {err}\",\n                ) from err\n\n        with open(pdf_path, \"wb\") as file:\n            file.write(response.content)\n            file.close()\n\n        return pdf_path\n", "path": "src/paperless_tika/parsers.py"}]}