JSONDecodeError when _convert_weaviate_result_to_document()
Hi,
I'm trying to write documents and update embeddings using WeaviateDocumentStore, and it seems to be a problem in _convert_weaviate_result_to_document() function.
The problem is here :
https://github.com/deepset-ai/haystack/blob/444a3116c42d2c8852d27aa8093ac92c8e85ab88/haystack/document_stores/weaviate.py#L242-L265
Line 242~253 is the sample result input dict of this function. And you can see result['properties']['content'] gets plain string text value 'text_5'
But, in Line 265, the content_field go into json.loads' input which should be dictionary formed string.
So this error occured :
File "/usr/local/lib/python3.9/dist-packages/haystack/document_stores/weaviate.py", line 1377, in update_embeddings document_batch = [ File "/usr/local/lib/python3.9/dist-packages/haystack/document_stores/weaviate.py", line 1378, in
self._convert_weaviate_result_to_document(hit, return_embedding=False) for hit in result_batch File "/usr/local/lib/python3.9/dist-packages/haystack/document_stores/weaviate.py", line 265, in _convert_weaviate_result_to_document content = json.loads(str(props.get(self.content_field))) File "/usr/lib/python3.9/json/init.py", line 346, in loads return _default_decoder.decode(s) File "/usr/lib/python3.9/json/decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/usr/lib/python3.9/json/decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I resolved this problem temporarily by changing Line 265 like this :
content = str(props.get(self.content_field))
Not content = json.loads(str(props.get(self.content_field)))
Is there a reason for using json.loads in that part? If so what should I do to run the code normally without fixing your weaviate.py code?
Hey, nice catch, can you please open a PR with the fix? Thanks!