mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
added validation of mongo url
This commit is contained in:
parent
23cc014f32
commit
0c00a50417
1 changed files with 8 additions and 0 deletions
|
|
@ -185,6 +185,14 @@ class OpenPypeMongoConnection:
|
|||
|
||||
@classmethod
|
||||
def create_connection(cls, mongo_url, timeout=None, retry_attempts=None):
|
||||
parsed = urlparse(mongo_url)
|
||||
# Force validation of scheme
|
||||
if parsed.scheme not in ["mongodb", "mongodb+srv"]:
|
||||
raise pymongo.errors.InvalidURI((
|
||||
"Invalid URI scheme:"
|
||||
" URI must begin with 'mongodb://' or 'mongodb+srv://'"
|
||||
))
|
||||
|
||||
if timeout is None:
|
||||
timeout = int(os.environ.get("AVALON_TIMEOUT") or 1000)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue