File tree 3 files changed +22
-4
lines changed
3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 3
3
from httpx import HTTPError , Response
4
4
5
5
from ..errors import FunctionsHttpError , FunctionsRelayError
6
- from ..utils import AsyncClient
6
+ from ..utils import AsyncClient , is_http_url , is_valid_str_arg
7
7
from ..version import __version__
8
8
9
9
@@ -16,6 +16,8 @@ def __init__(
16
16
verify : bool = True ,
17
17
proxy : Optional [str ] = None ,
18
18
):
19
+ if not is_http_url (url ):
20
+ ValueError ("url must be a valid HTTP URL string" )
19
21
self .url = url
20
22
self .headers = {
21
23
"User-Agent" : f"supabase-py/functions-py v{ __version__ } " ,
@@ -25,7 +27,7 @@ def __init__(
25
27
base_url = self .url ,
26
28
headers = self .headers ,
27
29
verify = bool (verify ),
28
- timeout = timeout ,
30
+ timeout = int ( abs ( timeout )) ,
29
31
proxy = proxy ,
30
32
follow_redirects = True ,
31
33
http2 = True ,
@@ -73,6 +75,8 @@ async def invoke(
73
75
`body`: the body of the request
74
76
`responseType`: how the response should be parsed. The default is `json`
75
77
"""
78
+ if not is_valid_str_arg (function_name ):
79
+ raise ValueError ("function_name must a valid string value." )
76
80
headers = self .headers
77
81
body = None
78
82
response_type = "text/plain"
Original file line number Diff line number Diff line change 3
3
from httpx import HTTPError , Response
4
4
5
5
from ..errors import FunctionsHttpError , FunctionsRelayError
6
- from ..utils import SyncClient
6
+ from ..utils import SyncClient , is_http_url , is_valid_str_arg
7
7
from ..version import __version__
8
8
9
9
@@ -16,6 +16,8 @@ def __init__(
16
16
verify : bool = True ,
17
17
proxy : Optional [str ] = None ,
18
18
):
19
+ if not is_http_url (url ):
20
+ ValueError ("url must be a valid HTTP URL string" )
19
21
self .url = url
20
22
self .headers = {
21
23
"User-Agent" : f"supabase-py/functions-py v{ __version__ } " ,
@@ -25,7 +27,7 @@ def __init__(
25
27
base_url = self .url ,
26
28
headers = self .headers ,
27
29
verify = bool (verify ),
28
- timeout = timeout ,
30
+ timeout = int ( abs ( timeout )) ,
29
31
proxy = proxy ,
30
32
follow_redirects = True ,
31
33
http2 = True ,
@@ -73,6 +75,8 @@ def invoke(
73
75
`body`: the body of the request
74
76
`responseType`: how the response should be parsed. The default is `json`
75
77
"""
78
+ if not is_valid_str_arg (function_name ):
79
+ raise ValueError ("function_name must a valid string value." )
76
80
headers = self .headers
77
81
body = None
78
82
response_type = "text/plain"
Original file line number Diff line number Diff line change
1
+ from urllib .parse import urlparse
2
+
1
3
from httpx import AsyncClient as AsyncClient # noqa: F401
2
4
from httpx import Client as BaseClient
3
5
7
9
class SyncClient (BaseClient ):
8
10
def aclose (self ) -> None :
9
11
self .close ()
12
+
13
+
14
+ def is_valid_str_arg (target : str ) -> bool :
15
+ return isinstance (target , str ) and len (target .strip ()) > 0
16
+
17
+
18
+ def is_http_url (url : str ) -> bool :
19
+ return urlparse (url ).scheme in {"https" , "http" }
You can’t perform that action at this time.
0 commit comments