File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed
v2/dirs/etc/sagemaker-ui/sagemaker-mcp
v3/dirs/etc/sagemaker-ui/sagemaker-mcp Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 66import json
77import logging
88import os
9+ import re
910from typing import Any , Dict
1011
1112from mcp .server .fastmcp import FastMCP
@@ -40,12 +41,12 @@ def __init__(self):
4041 except Exception as e :
4142 raise RuntimeError (f"Failed to initialize project: { e } " )
4243
43- if not self .domain_id :
44- raise RuntimeError (f"Domain id should not be empty " )
45- if not self .project_id :
46- raise RuntimeError (f"Project id should not be empty " )
47- if not self .region :
48- raise RuntimeError (f"Region should not be empty " )
44+ if not re . match ( "^dzd[-_][a-zA-Z0-9_-]{1,36}$" , self .domain_id ) :
45+ raise RuntimeError (f"Invalid domain id " )
46+ if not re . match ( "^[a-zA-Z0-9_-]{1,36}$" , self .project_id ) :
47+ raise RuntimeError (f"Invalid project id " )
48+ if not re . match ( "^[a-z]{2}-[a-z]{4,10}- \\ d$" , self .region ) :
49+ raise RuntimeError (f"Invalid region " )
4950
5051
5152def safe_get_attr (obj : Any , attr : str , default : Any = None ) -> Any :
Original file line number Diff line number Diff line change 66import json
77import logging
88import os
9+ import re
910from typing import Any , Dict
1011
1112from mcp .server .fastmcp import FastMCP
@@ -40,12 +41,12 @@ def __init__(self):
4041 except Exception as e :
4142 raise RuntimeError (f"Failed to initialize project: { e } " )
4243
43- if not self .domain_id :
44- raise RuntimeError (f"Domain id should not be empty " )
45- if not self .project_id :
46- raise RuntimeError (f"Project id should not be empty " )
47- if not self .region :
48- raise RuntimeError (f"Region should not be empty " )
44+ if not re . match ( "^dzd[-_][a-zA-Z0-9_-]{1,36}$" , self .domain_id ) :
45+ raise RuntimeError (f"Invalid domain id " )
46+ if not re . match ( "^[a-zA-Z0-9_-]{1,36}$" , self .project_id ) :
47+ raise RuntimeError (f"Invalid project id " )
48+ if not re . match ( "^[a-z]{2}-[a-z]{4,10}- \\ d$" , self .region ) :
49+ raise RuntimeError (f"Invalid region " )
4950
5051
5152def safe_get_attr (obj : Any , attr : str , default : Any = None ) -> Any :
You can’t perform that action at this time.
0 commit comments