We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Cant Upload a TXT file with REST API
**Describe the bug**
Cant Upload a TXT file with REST API, Receiving the following error

**Error message**
TyperError : 'NoneType' object does not support item assignment

**Expected behavior**
File gets uploaded to the ElasticSearch server and will return answers when asked a query through API 

**Additional context**
I am using a TXT file with  the /file-upload endpoint 
installed the REST API sever with Docker Compose GPU using the latest master branch code.

**To Reproduce**
Clone the Haystack repo
Run the docker GPU compose file. 
Use the curl command inside the GPU Machine to upload the file stored in the same machine with REST API Endpoint. 

**FAQ Check**
- [x] Have you had a look at [our new FAQ page](https://haystack.deepset.ai/overview/faq)?

**System:**
 - Hosting : AWS EC2 GPU instance (g3s.xlarge)
 - OS: Deep Learning Base AMI (Ubuntu 18.04) Version 44.0
 - GPU/CPU: GPU
 - Haystack version (commit or version number): db4d6f4
 - DocumentStore: ElasticSearch 
 - Reader: default (FARM)
 - Retriever: default (DPR)
![file-upload error](https://user-images.githubusercontent.com/93700661/153849332-3e23dd64-e62d-4184-8702-d89ef02d91a9.png)



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `rest_api/controller/file_upload.py`
Content:
```
1 from typing import Optional, List, Union
2 
3 import json
4 import logging
5 import os
6 import shutil
7 import uuid
8 from pathlib import Path
9 
10 from fastapi import APIRouter, UploadFile, File, Form, HTTPException, Depends
11 from pydantic import BaseModel
12 
13 from haystack.pipelines.base import Pipeline
14 from rest_api.config import PIPELINE_YAML_PATH, FILE_UPLOAD_PATH, INDEXING_PIPELINE_NAME
15 from rest_api.controller.utils import as_form
16 
17 
18 logger = logging.getLogger(__name__)
19 router = APIRouter()
20 
21 try:
22     pipeline_config = Pipeline._read_pipeline_config_from_yaml(Path(PIPELINE_YAML_PATH))
23     pipeline_definition = Pipeline._get_pipeline_definition(
24         pipeline_config=pipeline_config, pipeline_name=INDEXING_PIPELINE_NAME
25     )
26     definitions = Pipeline._get_component_definitions(
27         pipeline_config=pipeline_config, overwrite_with_env_variables=True
28     )
29     # Since each instance of FAISSDocumentStore creates an in-memory FAISS index, the Indexing & Query Pipelines would
30     # end up with different indices. The same applies for InMemoryDocumentStore. The check below prevents creation of
31     # Indexing Pipelines with FAISSDocumentStore or InMemoryDocumentStore.
32     is_faiss_or_inmemory_present = False
33     for node in pipeline_definition["nodes"]:
34         if (
35             definitions[node["name"]]["type"] == "FAISSDocumentStore"
36             or definitions[node["name"]]["type"] == "InMemoryDocumentStore"
37         ):
38             is_faiss_or_inmemory_present = True
39             break
40     if is_faiss_or_inmemory_present:
41         logger.warning(
42             "Indexing Pipeline with FAISSDocumentStore or InMemoryDocumentStore is not supported with the REST APIs."
43         )
44         INDEXING_PIPELINE = None
45     else:
46         INDEXING_PIPELINE = Pipeline.load_from_yaml(Path(PIPELINE_YAML_PATH), pipeline_name=INDEXING_PIPELINE_NAME)
47 except KeyError:
48     INDEXING_PIPELINE = None
49     logger.warning("Indexing Pipeline not found in the YAML configuration. File Upload API will not be available.")
50 
51 
52 # create directory for uploading files
53 os.makedirs(FILE_UPLOAD_PATH, exist_ok=True)
54 
55 
56 @as_form
57 class FileConverterParams(BaseModel):
58     remove_numeric_tables: Optional[bool] = None
59     valid_languages: Optional[List[str]] = None
60 
61 
62 @as_form
63 class PreprocessorParams(BaseModel):
64     clean_whitespace: Optional[bool] = None
65     clean_empty_lines: Optional[bool] = None
66     clean_header_footer: Optional[bool] = None
67     split_by: Optional[str] = None
68     split_length: Optional[int] = None
69     split_overlap: Optional[int] = None
70     split_respect_sentence_boundary: Optional[bool] = None
71 
72 
73 class Response(BaseModel):
74     file_id: str
75 
76 
77 @router.post("/file-upload")
78 def upload_file(
79     files: List[UploadFile] = File(...),
80     # JSON serialized string
81     meta: Optional[str] = Form("null"),  # type: ignore
82     fileconverter_params: FileConverterParams = Depends(FileConverterParams.as_form),  # type: ignore
83     preprocessor_params: PreprocessorParams = Depends(PreprocessorParams.as_form),  # type: ignore
84 ):
85     """
86     You can use this endpoint to upload a file for indexing
87     (see [http://localhost:3000/guides/rest-api#indexing-documents-in-the-haystack-rest-api-document-store]).
88     """
89     if not INDEXING_PIPELINE:
90         raise HTTPException(status_code=501, detail="Indexing Pipeline is not configured.")
91 
92     file_paths: list = []
93     file_metas: list = []
94     meta_form = json.loads(meta)  # type: ignore
95 
96     for file in files:
97         try:
98             file_path = Path(FILE_UPLOAD_PATH) / f"{uuid.uuid4().hex}_{file.filename}"
99             with file_path.open("wb") as buffer:
100                 shutil.copyfileobj(file.file, buffer)
101 
102             file_paths.append(file_path)
103             meta_form["name"] = file.filename
104             file_metas.append(meta_form)
105         finally:
106             file.file.close()
107 
108     INDEXING_PIPELINE.run(
109         file_paths=file_paths,
110         meta=file_metas,
111         params={
112             "TextFileConverter": fileconverter_params.dict(),
113             "PDFFileConverter": fileconverter_params.dict(),
114             "Preprocessor": preprocessor_params.dict(),
115         },
116     )
117
```
--- 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/rest_api/controller/file_upload.py b/rest_api/controller/file_upload.py
--- a/rest_api/controller/file_upload.py
+++ b/rest_api/controller/file_upload.py
@@ -91,7 +91,10 @@
 
     file_paths: list = []
     file_metas: list = []
-    meta_form = json.loads(meta)  # type: ignore
+
+    meta_form = json.loads(meta) or {}  # type: ignore
+    if not isinstance(meta_form, dict):
+        raise HTTPException(status_code=500, detail=f"The meta field must be a dict or None, not {type(meta_form)}")
 
     for file in files:
         try:

{"golden_diff": "diff --git a/rest_api/controller/file_upload.py b/rest_api/controller/file_upload.py\n--- a/rest_api/controller/file_upload.py\n+++ b/rest_api/controller/file_upload.py\n@@ -91,7 +91,10 @@\n \n     file_paths: list = []\n     file_metas: list = []\n-    meta_form = json.loads(meta)  # type: ignore\n+\n+    meta_form = json.loads(meta) or {}  # type: ignore\n+    if not isinstance(meta_form, dict):\n+        raise HTTPException(status_code=500, detail=f\"The meta field must be a dict or None, not {type(meta_form)}\")\n \n     for file in files:\n         try:\n", "issue": "Cant Upload a TXT file with REST API\n**Describe the bug**\r\nCant Upload a TXT file with REST API, Receiving the following error\r\n\r\n**Error message**\r\nTyperError : 'NoneType' object does not support item assignment\r\n\r\n**Expected behavior**\r\nFile gets uploaded to the ElasticSearch server and will return answers when asked a query through API \r\n\r\n**Additional context**\r\nI am using a TXT file with  the /file-upload endpoint \r\ninstalled the REST API sever with Docker Compose GPU using the latest master branch code.\r\n\r\n**To Reproduce**\r\nClone the Haystack repo\r\nRun the docker GPU compose file. \r\nUse the curl command inside the GPU Machine to upload the file stored in the same machine with REST API Endpoint. \r\n\r\n**FAQ Check**\r\n- [x] Have you had a look at [our new FAQ page](https://haystack.deepset.ai/overview/faq)?\r\n\r\n**System:**\r\n - Hosting : AWS EC2 GPU instance (g3s.xlarge)\r\n - OS: Deep Learning Base AMI (Ubuntu 18.04) Version 44.0\r\n - GPU/CPU: GPU\r\n - Haystack version (commit or version number): db4d6f4\r\n - DocumentStore: ElasticSearch \r\n - Reader: default (FARM)\r\n - Retriever: default (DPR)\r\n![file-upload error](https://user-images.githubusercontent.com/93700661/153849332-3e23dd64-e62d-4184-8702-d89ef02d91a9.png)\r\n\r\n\n", "before_files": [{"content": "from typing import Optional, List, Union\n\nimport json\nimport logging\nimport os\nimport shutil\nimport uuid\nfrom pathlib import Path\n\nfrom fastapi import APIRouter, UploadFile, File, Form, HTTPException, Depends\nfrom pydantic import BaseModel\n\nfrom haystack.pipelines.base import Pipeline\nfrom rest_api.config import PIPELINE_YAML_PATH, FILE_UPLOAD_PATH, INDEXING_PIPELINE_NAME\nfrom rest_api.controller.utils import as_form\n\n\nlogger = logging.getLogger(__name__)\nrouter = APIRouter()\n\ntry:\n    pipeline_config = Pipeline._read_pipeline_config_from_yaml(Path(PIPELINE_YAML_PATH))\n    pipeline_definition = Pipeline._get_pipeline_definition(\n        pipeline_config=pipeline_config, pipeline_name=INDEXING_PIPELINE_NAME\n    )\n    definitions = Pipeline._get_component_definitions(\n        pipeline_config=pipeline_config, overwrite_with_env_variables=True\n    )\n    # Since each instance of FAISSDocumentStore creates an in-memory FAISS index, the Indexing & Query Pipelines would\n    # end up with different indices. The same applies for InMemoryDocumentStore. The check below prevents creation of\n    # Indexing Pipelines with FAISSDocumentStore or InMemoryDocumentStore.\n    is_faiss_or_inmemory_present = False\n    for node in pipeline_definition[\"nodes\"]:\n        if (\n            definitions[node[\"name\"]][\"type\"] == \"FAISSDocumentStore\"\n            or definitions[node[\"name\"]][\"type\"] == \"InMemoryDocumentStore\"\n        ):\n            is_faiss_or_inmemory_present = True\n            break\n    if is_faiss_or_inmemory_present:\n        logger.warning(\n            \"Indexing Pipeline with FAISSDocumentStore or InMemoryDocumentStore is not supported with the REST APIs.\"\n        )\n        INDEXING_PIPELINE = None\n    else:\n        INDEXING_PIPELINE = Pipeline.load_from_yaml(Path(PIPELINE_YAML_PATH), pipeline_name=INDEXING_PIPELINE_NAME)\nexcept KeyError:\n    INDEXING_PIPELINE = None\n    logger.warning(\"Indexing Pipeline not found in the YAML configuration. File Upload API will not be available.\")\n\n\n# create directory for uploading files\nos.makedirs(FILE_UPLOAD_PATH, exist_ok=True)\n\n\n@as_form\nclass FileConverterParams(BaseModel):\n    remove_numeric_tables: Optional[bool] = None\n    valid_languages: Optional[List[str]] = None\n\n\n@as_form\nclass PreprocessorParams(BaseModel):\n    clean_whitespace: Optional[bool] = None\n    clean_empty_lines: Optional[bool] = None\n    clean_header_footer: Optional[bool] = None\n    split_by: Optional[str] = None\n    split_length: Optional[int] = None\n    split_overlap: Optional[int] = None\n    split_respect_sentence_boundary: Optional[bool] = None\n\n\nclass Response(BaseModel):\n    file_id: str\n\n\n@router.post(\"/file-upload\")\ndef upload_file(\n    files: List[UploadFile] = File(...),\n    # JSON serialized string\n    meta: Optional[str] = Form(\"null\"),  # type: ignore\n    fileconverter_params: FileConverterParams = Depends(FileConverterParams.as_form),  # type: ignore\n    preprocessor_params: PreprocessorParams = Depends(PreprocessorParams.as_form),  # type: ignore\n):\n    \"\"\"\n    You can use this endpoint to upload a file for indexing\n    (see [http://localhost:3000/guides/rest-api#indexing-documents-in-the-haystack-rest-api-document-store]).\n    \"\"\"\n    if not INDEXING_PIPELINE:\n        raise HTTPException(status_code=501, detail=\"Indexing Pipeline is not configured.\")\n\n    file_paths: list = []\n    file_metas: list = []\n    meta_form = json.loads(meta)  # type: ignore\n\n    for file in files:\n        try:\n            file_path = Path(FILE_UPLOAD_PATH) / f\"{uuid.uuid4().hex}_{file.filename}\"\n            with file_path.open(\"wb\") as buffer:\n                shutil.copyfileobj(file.file, buffer)\n\n            file_paths.append(file_path)\n            meta_form[\"name\"] = file.filename\n            file_metas.append(meta_form)\n        finally:\n            file.file.close()\n\n    INDEXING_PIPELINE.run(\n        file_paths=file_paths,\n        meta=file_metas,\n        params={\n            \"TextFileConverter\": fileconverter_params.dict(),\n            \"PDFFileConverter\": fileconverter_params.dict(),\n            \"Preprocessor\": preprocessor_params.dict(),\n        },\n    )\n", "path": "rest_api/controller/file_upload.py"}], "after_files": [{"content": "from typing import Optional, List, Union\n\nimport json\nimport logging\nimport os\nimport shutil\nimport uuid\nfrom pathlib import Path\n\nfrom fastapi import APIRouter, UploadFile, File, Form, HTTPException, Depends\nfrom pydantic import BaseModel\n\nfrom haystack.pipelines.base import Pipeline\nfrom rest_api.config import PIPELINE_YAML_PATH, FILE_UPLOAD_PATH, INDEXING_PIPELINE_NAME\nfrom rest_api.controller.utils import as_form\n\n\nlogger = logging.getLogger(__name__)\nrouter = APIRouter()\n\ntry:\n    pipeline_config = Pipeline._read_pipeline_config_from_yaml(Path(PIPELINE_YAML_PATH))\n    pipeline_definition = Pipeline._get_pipeline_definition(\n        pipeline_config=pipeline_config, pipeline_name=INDEXING_PIPELINE_NAME\n    )\n    definitions = Pipeline._get_component_definitions(\n        pipeline_config=pipeline_config, overwrite_with_env_variables=True\n    )\n    # Since each instance of FAISSDocumentStore creates an in-memory FAISS index, the Indexing & Query Pipelines would\n    # end up with different indices. The same applies for InMemoryDocumentStore. The check below prevents creation of\n    # Indexing Pipelines with FAISSDocumentStore or InMemoryDocumentStore.\n    is_faiss_or_inmemory_present = False\n    for node in pipeline_definition[\"nodes\"]:\n        if (\n            definitions[node[\"name\"]][\"type\"] == \"FAISSDocumentStore\"\n            or definitions[node[\"name\"]][\"type\"] == \"InMemoryDocumentStore\"\n        ):\n            is_faiss_or_inmemory_present = True\n            break\n    if is_faiss_or_inmemory_present:\n        logger.warning(\n            \"Indexing Pipeline with FAISSDocumentStore or InMemoryDocumentStore is not supported with the REST APIs.\"\n        )\n        INDEXING_PIPELINE = None\n    else:\n        INDEXING_PIPELINE = Pipeline.load_from_yaml(Path(PIPELINE_YAML_PATH), pipeline_name=INDEXING_PIPELINE_NAME)\nexcept KeyError:\n    INDEXING_PIPELINE = None\n    logger.warning(\"Indexing Pipeline not found in the YAML configuration. File Upload API will not be available.\")\n\n\n# create directory for uploading files\nos.makedirs(FILE_UPLOAD_PATH, exist_ok=True)\n\n\n@as_form\nclass FileConverterParams(BaseModel):\n    remove_numeric_tables: Optional[bool] = None\n    valid_languages: Optional[List[str]] = None\n\n\n@as_form\nclass PreprocessorParams(BaseModel):\n    clean_whitespace: Optional[bool] = None\n    clean_empty_lines: Optional[bool] = None\n    clean_header_footer: Optional[bool] = None\n    split_by: Optional[str] = None\n    split_length: Optional[int] = None\n    split_overlap: Optional[int] = None\n    split_respect_sentence_boundary: Optional[bool] = None\n\n\nclass Response(BaseModel):\n    file_id: str\n\n\n@router.post(\"/file-upload\")\ndef upload_file(\n    files: List[UploadFile] = File(...),\n    # JSON serialized string\n    meta: Optional[str] = Form(\"null\"),  # type: ignore\n    fileconverter_params: FileConverterParams = Depends(FileConverterParams.as_form),  # type: ignore\n    preprocessor_params: PreprocessorParams = Depends(PreprocessorParams.as_form),  # type: ignore\n):\n    \"\"\"\n    You can use this endpoint to upload a file for indexing\n    (see [http://localhost:3000/guides/rest-api#indexing-documents-in-the-haystack-rest-api-document-store]).\n    \"\"\"\n    if not INDEXING_PIPELINE:\n        raise HTTPException(status_code=501, detail=\"Indexing Pipeline is not configured.\")\n\n    file_paths: list = []\n    file_metas: list = []\n\n    meta_form = json.loads(meta) or {}  # type: ignore\n    if not isinstance(meta_form, dict):\n        raise HTTPException(status_code=500, detail=f\"The meta field must be a dict or None, not {type(meta_form)}\")\n\n    for file in files:\n        try:\n            file_path = Path(FILE_UPLOAD_PATH) / f\"{uuid.uuid4().hex}_{file.filename}\"\n            with file_path.open(\"wb\") as buffer:\n                shutil.copyfileobj(file.file, buffer)\n\n            file_paths.append(file_path)\n            meta_form[\"name\"] = file.filename\n            file_metas.append(meta_form)\n        finally:\n            file.file.close()\n\n    INDEXING_PIPELINE.run(\n        file_paths=file_paths,\n        meta=file_metas,\n        params={\n            \"TextFileConverter\": fileconverter_params.dict(),\n            \"PDFFileConverter\": fileconverter_params.dict(),\n            \"Preprocessor\": preprocessor_params.dict(),\n        },\n    )\n", "path": "rest_api/controller/file_upload.py"}]}