File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -80,6 +80,16 @@ def send_request(
80
80
raise MeilisearchTimeoutError (str (err )) from err
81
81
except requests .exceptions .ConnectionError as err :
82
82
raise MeilisearchCommunicationError (str (err )) from err
83
+ except requests .exceptions .InvalidSchema as err :
84
+ if "://" not in self .config .url :
85
+ raise MeilisearchCommunicationError (
86
+ f"""
87
+ Invalid URL { self .config .url } , no scheme/protocol supplied.
88
+ Did you mean https://{ self .config .url } ?
89
+ """
90
+ ) from err
91
+
92
+ raise MeilisearchCommunicationError (str (err )) from err
83
93
84
94
def get (self , path : str ) -> Any :
85
95
return self .send_request (requests .get , path )
Original file line number Diff line number Diff line change @@ -17,3 +17,12 @@ def test_meilisearch_communication_error_host(mock_post):
17
17
client = meilisearch .Client ("http://wrongurl:1234" , MASTER_KEY )
18
18
with pytest .raises (MeilisearchCommunicationError ):
19
19
client .create_index ("some_index" )
20
+
21
+
22
+ @patch ("requests.post" )
23
+ def test_meilisearch_communication_error_no_protocol (mock_post ):
24
+ mock_post .configure_mock (__name__ = "post" )
25
+ mock_post .side_effect = requests .exceptions .InvalidSchema ()
26
+ client = meilisearch .Client ("localhost:7700" , MASTER_KEY )
27
+ with pytest .raises (MeilisearchCommunicationError , match = "no scheme/protocol supplied." ):
28
+ client .create_index ("some_index" )
You can’t perform that action at this time.
0 commit comments