@@ -151,6 +151,38 @@ def is_config_valid_internally(
151151 """
152152 invalid_runners = set ()
153153
154+ def validate_ami_format (
155+ runner_type : str , ami_value : str , context : str = ""
156+ ) -> bool :
157+ """Validate AMI format with separator '|' containing AMI Name|AWS Account"""
158+ if "|" in ami_value :
159+ ami_parts = ami_value .split ("|" )
160+ if len (ami_parts ) != 2 :
161+ print (
162+ f"Runner type { runner_type } { context } has invalid AMI format: { ami_value } (expected format: AMI_Name|AWS_Account)"
163+ )
164+ return False
165+
166+ ami_name , aws_account = ami_parts
167+ ami_name = ami_name .strip ()
168+ aws_account = aws_account .strip ()
169+
170+ # Validate AWS account format - should be all digits
171+ if not aws_account .isdigit ():
172+ print (
173+ f"Runner type { runner_type } { context } has invalid AWS account format: { aws_account } (AWS account must be all digits)"
174+ )
175+ return False
176+
177+ # Basic validation that AMI name is not empty
178+ if not ami_name :
179+ print (
180+ f"Runner type { runner_type } { context } has empty AMI name in: { ami_value } "
181+ )
182+ return False
183+
184+ return True
185+
154186 for runner_type , runner_config in runner_types .items ():
155187 try :
156188 jsonschema .validate (runner_config , RUNNER_JSCHEMA )
@@ -167,6 +199,25 @@ def is_config_valid_internally(
167199 if "max_available" not in runner_config :
168200 continue
169201
202+ # Validate variants if they exist
203+ if "variants" in runner_config :
204+ variants = runner_config ["variants" ]
205+ if not isinstance (variants , dict ):
206+ print (
207+ f"Runner type { runner_type } has invalid variants configuration: must be a dictionary"
208+ )
209+ invalid_runners .add (runner_type )
210+ else :
211+ for variant_name , variant_config in variants .items ():
212+ # Validate AMI format in variants if present
213+ if "ami" in variant_config :
214+ if not validate_ami_format (
215+ runner_type ,
216+ variant_config ["ami" ],
217+ f" variant '{ variant_name } '" ,
218+ ):
219+ invalid_runners .add (runner_type )
220+
170221 if runner_config ["max_available" ] == None :
171222 print (
172223 f"Runner type { runner_type } can't have max_available set to Null, Python, "
0 commit comments