This repository was archived by the owner on Aug 22, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Expand file tree Collapse file tree 3 files changed +22
-4
lines changed Original file line number Diff line number Diff line change 33from httpx import HTTPError , Response
44
55from ..errors import FunctionsHttpError , FunctionsRelayError
6- from ..utils import AsyncClient
6+ from ..utils import AsyncClient , is_http_url , is_valid_str_arg
77from ..version import __version__
88
99
@@ -16,6 +16,8 @@ def __init__(
1616 verify : bool = True ,
1717 proxy : Optional [str ] = None ,
1818 ):
19+ if not is_http_url (url ):
20+ ValueError ("url must be a valid HTTP URL string" )
1921 self .url = url
2022 self .headers = {
2123 "User-Agent" : f"supabase-py/functions-py v{ __version__ } " ,
@@ -25,7 +27,7 @@ def __init__(
2527 base_url = self .url ,
2628 headers = self .headers ,
2729 verify = bool (verify ),
28- timeout = timeout ,
30+ timeout = int ( abs ( timeout )) ,
2931 proxy = proxy ,
3032 follow_redirects = True ,
3133 http2 = True ,
@@ -73,6 +75,8 @@ async def invoke(
7375 `body`: the body of the request
7476 `responseType`: how the response should be parsed. The default is `json`
7577 """
78+ if not is_valid_str_arg (function_name ):
79+ raise ValueError ("function_name must a valid string value." )
7680 headers = self .headers
7781 body = None
7882 response_type = "text/plain"
Original file line number Diff line number Diff line change 33from httpx import HTTPError , Response
44
55from ..errors import FunctionsHttpError , FunctionsRelayError
6- from ..utils import SyncClient
6+ from ..utils import SyncClient , is_http_url , is_valid_str_arg
77from ..version import __version__
88
99
@@ -16,6 +16,8 @@ def __init__(
1616 verify : bool = True ,
1717 proxy : Optional [str ] = None ,
1818 ):
19+ if not is_http_url (url ):
20+ ValueError ("url must be a valid HTTP URL string" )
1921 self .url = url
2022 self .headers = {
2123 "User-Agent" : f"supabase-py/functions-py v{ __version__ } " ,
@@ -25,7 +27,7 @@ def __init__(
2527 base_url = self .url ,
2628 headers = self .headers ,
2729 verify = bool (verify ),
28- timeout = timeout ,
30+ timeout = int ( abs ( timeout )) ,
2931 proxy = proxy ,
3032 follow_redirects = True ,
3133 http2 = True ,
@@ -73,6 +75,8 @@ def invoke(
7375 `body`: the body of the request
7476 `responseType`: how the response should be parsed. The default is `json`
7577 """
78+ if not is_valid_str_arg (function_name ):
79+ raise ValueError ("function_name must a valid string value." )
7680 headers = self .headers
7781 body = None
7882 response_type = "text/plain"
Original file line number Diff line number Diff line change 1+ from urllib .parse import urlparse
2+
13from httpx import AsyncClient as AsyncClient # noqa: F401
24from httpx import Client as BaseClient
35
79class SyncClient (BaseClient ):
810 def aclose (self ) -> None :
911 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