We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Cannot search for keywords via Global Search
Steps:

1. Enter any keyword in global search
2. Hit enter
3. Instead of returning relevant records, system throws error message for Relevant Doctype

![image](https://user-images.githubusercontent.com/33246109/144895257-654ecb0e-e849-4087-b3f3-037219c67c77.png)

```
Traceback (most recent call last):
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/app.py", line 66, in application
    response = frappe.api.handle()
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/api.py", line 54, in handle
    return frappe.handler.handle()
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/handler.py", line 31, in handle
    data = execute_cmd(cmd)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/handler.py", line 67, in execute_cmd
    return frappe.call(method, **frappe.form_dict)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py", line 1213, in call
    return fn(*args, **newargs)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/utils/global_search.py", line 422, in search
    allowed_doctypes = get_doctypes_for_global_search()
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/desk/doctype/global_search_settings/global_search_settings.py", line 39, in get_doctypes_for_global_search
    return frappe.cache().hget("global_search", "search_priorities", get_from_db)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/utils/redis_wrapper.py", line 194, in hget
    value = generator()
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/desk/doctype/global_search_settings/global_search_settings.py", line 36, in get_from_db
    doctypes = frappe.get_list("Global Search DocType", fields=["document_type"], order_by="idx ASC")
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py", line 1446, in get_list
    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/model/db_query.py", line 40, in execute
    not frappe.has_permission(self.doctype, "select", user=user, parent_doctype=parent_doctype) and \
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py", line 743, in has_permission
    raise_exception=throw, parent_doctype=parent_doctype)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/permissions.py", line 24, in inner
    result = func(*args, **kwargs)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/permissions.py", line 55, in has_permission
    user, raise_exception, parent_doctype)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/permissions.py", line 585, in has_child_table_permission
    ), title=_("Parent DocType Required"))
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py", line 438, in throw
    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py", line 417, in msgprint
    _raise_exception()
  File "/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py", line 371, in _raise_exception
    raise raise_exception(msg)
frappe.exceptions.ValidationError: Please specify a valid parent DocType for <strong>Global Search DocType</strong>
```

ERPNext: v13.x.x-develop () (develop)

Frappe Framework: v14.x.x-develop () (develop)



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `frappe/desk/doctype/global_search_settings/global_search_settings.py`
Content:
```
1 # -*- coding: utf-8 -*-
2 # Copyright (c) 2019, Frappe Technologies and contributors
3 # License: MIT. See LICENSE
4 
5 import frappe
6 from frappe.model.document import Document
7 from frappe import _
8 
9 class GlobalSearchSettings(Document):
10 
11 	def validate(self):
12 		dts, core_dts, repeated_dts = [], [], []
13 
14 		for dt in self.allowed_in_global_search:
15 			if dt.document_type in dts:
16 				repeated_dts.append(dt.document_type)
17 
18 			if frappe.get_meta(dt.document_type).module == "Core":
19 				core_dts.append(dt.document_type)
20 
21 			dts.append(dt.document_type)
22 
23 		if core_dts:
24 			core_dts = ", ".join(frappe.bold(dt) for dt in core_dts)
25 			frappe.throw(_("Core Modules {0} cannot be searched in Global Search.").format(core_dts))
26 
27 		if repeated_dts:
28 			repeated_dts = (", ".join([frappe.bold(dt) for dt in repeated_dts]))
29 			frappe.throw(_("Document Type {0} has been repeated.").format(repeated_dts))
30 
31 		# reset cache
32 		frappe.cache().hdel('global_search', 'search_priorities')
33 
34 def get_doctypes_for_global_search():
35 	def get_from_db():
36 		doctypes = frappe.get_list("Global Search DocType", fields=["document_type"], order_by="idx ASC")
37 		return [d.document_type for d in doctypes] or []
38 
39 	return frappe.cache().hget("global_search", "search_priorities", get_from_db)
40 
41 
42 @frappe.whitelist()
43 def reset_global_search_settings_doctypes():
44 	update_global_search_doctypes()
45 
46 def update_global_search_doctypes():
47 	global_search_doctypes = []
48 	show_message(1, _("Fetching default Global Search documents."))
49 
50 	installed_apps = [app for app in frappe.get_installed_apps() if app]
51 	active_domains = [domain for domain in frappe.get_active_domains() if domain]
52 	active_domains.append("Default")
53 
54 	for app in installed_apps:
55 		search_doctypes = frappe.get_hooks(hook="global_search_doctypes", app_name=app)
56 		if not search_doctypes:
57 			continue
58 
59 		for domain in active_domains:
60 			if search_doctypes.get(domain):
61 				global_search_doctypes.extend(search_doctypes.get(domain))
62 
63 	doctype_list = {dt.name for dt in frappe.get_all("DocType")}
64 	allowed_in_global_search = []
65 
66 	for dt in global_search_doctypes:
67 		if dt.get("index") is not None:
68 			allowed_in_global_search.insert(dt.get("index"), dt.get("doctype"))
69 			continue
70 
71 		allowed_in_global_search.append(dt.get("doctype"))
72 
73 	show_message(2, _("Setting up Global Search documents."))
74 	global_search_settings = frappe.get_single("Global Search Settings")
75 	global_search_settings.allowed_in_global_search = []
76 	for dt in allowed_in_global_search:
77 		if dt not in doctype_list:
78 			continue
79 
80 		global_search_settings.append("allowed_in_global_search", {
81 			"document_type": dt
82 		})
83 	global_search_settings.save(ignore_permissions=True)
84 	show_message(3, "Global Search Documents have been reset.")
85 
86 def show_message(progress, msg):
87 	frappe.publish_realtime('global_search_settings', {"progress":progress, "total":3, "msg": msg}, user=frappe.session.user)
88
```
--- 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/frappe/desk/doctype/global_search_settings/global_search_settings.py b/frappe/desk/doctype/global_search_settings/global_search_settings.py
--- a/frappe/desk/doctype/global_search_settings/global_search_settings.py
+++ b/frappe/desk/doctype/global_search_settings/global_search_settings.py
@@ -33,7 +33,7 @@
 
 def get_doctypes_for_global_search():
 	def get_from_db():
-		doctypes = frappe.get_list("Global Search DocType", fields=["document_type"], order_by="idx ASC")
+		doctypes = frappe.get_all("Global Search DocType", fields=["document_type"], order_by="idx ASC")
 		return [d.document_type for d in doctypes] or []
 
 	return frappe.cache().hget("global_search", "search_priorities", get_from_db)

{"golden_diff": "diff --git a/frappe/desk/doctype/global_search_settings/global_search_settings.py b/frappe/desk/doctype/global_search_settings/global_search_settings.py\n--- a/frappe/desk/doctype/global_search_settings/global_search_settings.py\n+++ b/frappe/desk/doctype/global_search_settings/global_search_settings.py\n@@ -33,7 +33,7 @@\n \n def get_doctypes_for_global_search():\n \tdef get_from_db():\n-\t\tdoctypes = frappe.get_list(\"Global Search DocType\", fields=[\"document_type\"], order_by=\"idx ASC\")\n+\t\tdoctypes = frappe.get_all(\"Global Search DocType\", fields=[\"document_type\"], order_by=\"idx ASC\")\n \t\treturn [d.document_type for d in doctypes] or []\n \n \treturn frappe.cache().hget(\"global_search\", \"search_priorities\", get_from_db)\n", "issue": "Cannot search for keywords via Global Search\nSteps:\r\n\r\n1. Enter any keyword in global search\r\n2. Hit enter\r\n3. Instead of returning relevant records, system throws error message for Relevant Doctype\r\n\r\n![image](https://user-images.githubusercontent.com/33246109/144895257-654ecb0e-e849-4087-b3f3-037219c67c77.png)\r\n\r\n```\r\nTraceback (most recent call last):\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/app.py\", line 66, in application\r\n    response = frappe.api.handle()\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/api.py\", line 54, in handle\r\n    return frappe.handler.handle()\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/handler.py\", line 31, in handle\r\n    data = execute_cmd(cmd)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/handler.py\", line 67, in execute_cmd\r\n    return frappe.call(method, **frappe.form_dict)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py\", line 1213, in call\r\n    return fn(*args, **newargs)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/utils/global_search.py\", line 422, in search\r\n    allowed_doctypes = get_doctypes_for_global_search()\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/desk/doctype/global_search_settings/global_search_settings.py\", line 39, in get_doctypes_for_global_search\r\n    return frappe.cache().hget(\"global_search\", \"search_priorities\", get_from_db)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/utils/redis_wrapper.py\", line 194, in hget\r\n    value = generator()\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/desk/doctype/global_search_settings/global_search_settings.py\", line 36, in get_from_db\r\n    doctypes = frappe.get_list(\"Global Search DocType\", fields=[\"document_type\"], order_by=\"idx ASC\")\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py\", line 1446, in get_list\r\n    return frappe.model.db_query.DatabaseQuery(doctype).execute(*args, **kwargs)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/model/db_query.py\", line 40, in execute\r\n    not frappe.has_permission(self.doctype, \"select\", user=user, parent_doctype=parent_doctype) and \\\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py\", line 743, in has_permission\r\n    raise_exception=throw, parent_doctype=parent_doctype)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/permissions.py\", line 24, in inner\r\n    result = func(*args, **kwargs)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/permissions.py\", line 55, in has_permission\r\n    user, raise_exception, parent_doctype)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/permissions.py\", line 585, in has_child_table_permission\r\n    ), title=_(\"Parent DocType Required\"))\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py\", line 438, in throw\r\n    msgprint(msg, raise_exception=exc, title=title, indicator='red', is_minimizable=is_minimizable, wide=wide, as_list=as_list)\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py\", line 417, in msgprint\r\n    _raise_exception()\r\n  File \"/home/frappe/frappe-io-bench/apps/frappe/frappe/__init__.py\", line 371, in _raise_exception\r\n    raise raise_exception(msg)\r\nfrappe.exceptions.ValidationError: Please specify a valid parent DocType for <strong>Global Search DocType</strong>\r\n```\r\n\r\nERPNext: v13.x.x-develop () (develop)\r\n\r\nFrappe Framework: v14.x.x-develop () (develop)\r\n\r\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) 2019, Frappe Technologies and contributors\n# License: MIT. See LICENSE\n\nimport frappe\nfrom frappe.model.document import Document\nfrom frappe import _\n\nclass GlobalSearchSettings(Document):\n\n\tdef validate(self):\n\t\tdts, core_dts, repeated_dts = [], [], []\n\n\t\tfor dt in self.allowed_in_global_search:\n\t\t\tif dt.document_type in dts:\n\t\t\t\trepeated_dts.append(dt.document_type)\n\n\t\t\tif frappe.get_meta(dt.document_type).module == \"Core\":\n\t\t\t\tcore_dts.append(dt.document_type)\n\n\t\t\tdts.append(dt.document_type)\n\n\t\tif core_dts:\n\t\t\tcore_dts = \", \".join(frappe.bold(dt) for dt in core_dts)\n\t\t\tfrappe.throw(_(\"Core Modules {0} cannot be searched in Global Search.\").format(core_dts))\n\n\t\tif repeated_dts:\n\t\t\trepeated_dts = (\", \".join([frappe.bold(dt) for dt in repeated_dts]))\n\t\t\tfrappe.throw(_(\"Document Type {0} has been repeated.\").format(repeated_dts))\n\n\t\t# reset cache\n\t\tfrappe.cache().hdel('global_search', 'search_priorities')\n\ndef get_doctypes_for_global_search():\n\tdef get_from_db():\n\t\tdoctypes = frappe.get_list(\"Global Search DocType\", fields=[\"document_type\"], order_by=\"idx ASC\")\n\t\treturn [d.document_type for d in doctypes] or []\n\n\treturn frappe.cache().hget(\"global_search\", \"search_priorities\", get_from_db)\n\n\n@frappe.whitelist()\ndef reset_global_search_settings_doctypes():\n\tupdate_global_search_doctypes()\n\ndef update_global_search_doctypes():\n\tglobal_search_doctypes = []\n\tshow_message(1, _(\"Fetching default Global Search documents.\"))\n\n\tinstalled_apps = [app for app in frappe.get_installed_apps() if app]\n\tactive_domains = [domain for domain in frappe.get_active_domains() if domain]\n\tactive_domains.append(\"Default\")\n\n\tfor app in installed_apps:\n\t\tsearch_doctypes = frappe.get_hooks(hook=\"global_search_doctypes\", app_name=app)\n\t\tif not search_doctypes:\n\t\t\tcontinue\n\n\t\tfor domain in active_domains:\n\t\t\tif search_doctypes.get(domain):\n\t\t\t\tglobal_search_doctypes.extend(search_doctypes.get(domain))\n\n\tdoctype_list = {dt.name for dt in frappe.get_all(\"DocType\")}\n\tallowed_in_global_search = []\n\n\tfor dt in global_search_doctypes:\n\t\tif dt.get(\"index\") is not None:\n\t\t\tallowed_in_global_search.insert(dt.get(\"index\"), dt.get(\"doctype\"))\n\t\t\tcontinue\n\n\t\tallowed_in_global_search.append(dt.get(\"doctype\"))\n\n\tshow_message(2, _(\"Setting up Global Search documents.\"))\n\tglobal_search_settings = frappe.get_single(\"Global Search Settings\")\n\tglobal_search_settings.allowed_in_global_search = []\n\tfor dt in allowed_in_global_search:\n\t\tif dt not in doctype_list:\n\t\t\tcontinue\n\n\t\tglobal_search_settings.append(\"allowed_in_global_search\", {\n\t\t\t\"document_type\": dt\n\t\t})\n\tglobal_search_settings.save(ignore_permissions=True)\n\tshow_message(3, \"Global Search Documents have been reset.\")\n\ndef show_message(progress, msg):\n\tfrappe.publish_realtime('global_search_settings', {\"progress\":progress, \"total\":3, \"msg\": msg}, user=frappe.session.user)\n", "path": "frappe/desk/doctype/global_search_settings/global_search_settings.py"}], "after_files": [{"content": "# -*- coding: utf-8 -*-\n# Copyright (c) 2019, Frappe Technologies and contributors\n# License: MIT. See LICENSE\n\nimport frappe\nfrom frappe.model.document import Document\nfrom frappe import _\n\nclass GlobalSearchSettings(Document):\n\n\tdef validate(self):\n\t\tdts, core_dts, repeated_dts = [], [], []\n\n\t\tfor dt in self.allowed_in_global_search:\n\t\t\tif dt.document_type in dts:\n\t\t\t\trepeated_dts.append(dt.document_type)\n\n\t\t\tif frappe.get_meta(dt.document_type).module == \"Core\":\n\t\t\t\tcore_dts.append(dt.document_type)\n\n\t\t\tdts.append(dt.document_type)\n\n\t\tif core_dts:\n\t\t\tcore_dts = \", \".join(frappe.bold(dt) for dt in core_dts)\n\t\t\tfrappe.throw(_(\"Core Modules {0} cannot be searched in Global Search.\").format(core_dts))\n\n\t\tif repeated_dts:\n\t\t\trepeated_dts = (\", \".join([frappe.bold(dt) for dt in repeated_dts]))\n\t\t\tfrappe.throw(_(\"Document Type {0} has been repeated.\").format(repeated_dts))\n\n\t\t# reset cache\n\t\tfrappe.cache().hdel('global_search', 'search_priorities')\n\ndef get_doctypes_for_global_search():\n\tdef get_from_db():\n\t\tdoctypes = frappe.get_all(\"Global Search DocType\", fields=[\"document_type\"], order_by=\"idx ASC\")\n\t\treturn [d.document_type for d in doctypes] or []\n\n\treturn frappe.cache().hget(\"global_search\", \"search_priorities\", get_from_db)\n\n\n@frappe.whitelist()\ndef reset_global_search_settings_doctypes():\n\tupdate_global_search_doctypes()\n\ndef update_global_search_doctypes():\n\tglobal_search_doctypes = []\n\tshow_message(1, _(\"Fetching default Global Search documents.\"))\n\n\tinstalled_apps = [app for app in frappe.get_installed_apps() if app]\n\tactive_domains = [domain for domain in frappe.get_active_domains() if domain]\n\tactive_domains.append(\"Default\")\n\n\tfor app in installed_apps:\n\t\tsearch_doctypes = frappe.get_hooks(hook=\"global_search_doctypes\", app_name=app)\n\t\tif not search_doctypes:\n\t\t\tcontinue\n\n\t\tfor domain in active_domains:\n\t\t\tif search_doctypes.get(domain):\n\t\t\t\tglobal_search_doctypes.extend(search_doctypes.get(domain))\n\n\tdoctype_list = {dt.name for dt in frappe.get_all(\"DocType\")}\n\tallowed_in_global_search = []\n\n\tfor dt in global_search_doctypes:\n\t\tif dt.get(\"index\") is not None:\n\t\t\tallowed_in_global_search.insert(dt.get(\"index\"), dt.get(\"doctype\"))\n\t\t\tcontinue\n\n\t\tallowed_in_global_search.append(dt.get(\"doctype\"))\n\n\tshow_message(2, _(\"Setting up Global Search documents.\"))\n\tglobal_search_settings = frappe.get_single(\"Global Search Settings\")\n\tglobal_search_settings.allowed_in_global_search = []\n\tfor dt in allowed_in_global_search:\n\t\tif dt not in doctype_list:\n\t\t\tcontinue\n\n\t\tglobal_search_settings.append(\"allowed_in_global_search\", {\n\t\t\t\"document_type\": dt\n\t\t})\n\tglobal_search_settings.save(ignore_permissions=True)\n\tshow_message(3, \"Global Search Documents have been reset.\")\n\ndef show_message(progress, msg):\n\tfrappe.publish_realtime('global_search_settings', {\"progress\":progress, \"total\":3, \"msg\": msg}, user=frappe.session.user)\n", "path": "frappe/desk/doctype/global_search_settings/global_search_settings.py"}]}