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 6
6
import json
7
7
import logging
8
8
import os
9
+ import re
9
10
from typing import Any , Dict
10
11
11
12
from mcp .server .fastmcp import FastMCP
@@ -40,12 +41,12 @@ def __init__(self):
40
41
except Exception as e :
41
42
raise RuntimeError (f"Failed to initialize project: { e } " )
42
43
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 " )
49
50
50
51
51
52
def safe_get_attr (obj : Any , attr : str , default : Any = None ) -> Any :
Original file line number Diff line number Diff line change 6
6
import json
7
7
import logging
8
8
import os
9
+ import re
9
10
from typing import Any , Dict
10
11
11
12
from mcp .server .fastmcp import FastMCP
@@ -40,12 +41,12 @@ def __init__(self):
40
41
except Exception as e :
41
42
raise RuntimeError (f"Failed to initialize project: { e } " )
42
43
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 " )
49
50
50
51
51
52
def safe_get_attr (obj : Any , attr : str , default : Any = None ) -> Any :
You can’t perform that action at this time.
0 commit comments