@@ -1049,8 +1049,21 @@ def feature_request_human_input(
10491049 ftype = field .get ("type" , "text" )
10501050 if ftype not in VALID_FIELD_TYPES :
10511051 return json .dumps ({"error" : f"Field at index { i } has invalid type '{ ftype } '. Must be one of: { ', ' .join (sorted (VALID_FIELD_TYPES ))} " })
1052- if ftype == "select" and not field .get ("options" ):
1053- return json .dumps ({"error" : f"Field at index { i } is type 'select' but missing 'options' array" })
1052+ if ftype == "select" :
1053+ options = field .get ("options" )
1054+ if not options or not isinstance (options , list ):
1055+ return json .dumps ({"error" : f"Field at index { i } is type 'select' but missing or invalid 'options' array" })
1056+ for j , opt in enumerate (options ):
1057+ if not isinstance (opt , dict ):
1058+ return json .dumps ({"error" : f"Field at index { i } , option { j } must be an object with 'value' and 'label'" })
1059+ if "value" not in opt or "label" not in opt :
1060+ return json .dumps ({"error" : f"Field at index { i } , option { j } missing required 'value' or 'label'" })
1061+ if not isinstance (opt ["value" ], str ) or not opt ["value" ].strip ():
1062+ return json .dumps ({"error" : f"Field at index { i } , option { j } has empty or invalid 'value'" })
1063+ if not isinstance (opt ["label" ], str ) or not opt ["label" ].strip ():
1064+ return json .dumps ({"error" : f"Field at index { i } , option { j } has empty or invalid 'label'" })
1065+ elif field .get ("options" ):
1066+ return json .dumps ({"error" : f"Field at index { i } has 'options' but type is '{ ftype } ' (only 'select' uses options)" })
10541067
10551068 request_data = {
10561069 "prompt" : prompt ,
0 commit comments