@@ -188,8 +188,10 @@ def ts_data(ts):
188
188
189
189
def determine_aggregation_function (function_name ):
190
190
"""
191
- Return the aggregation function associated to the provided function name. This is used by
192
- dropdown menus that allow selecting from multiple aggregation functions.
191
+ Return the aggregation function associated to the provided function name, or None if
192
+ the function name is unsupported.
193
+
194
+ This is used by dropdown menus that allow selecting from multiple aggregation functions.
193
195
"""
194
196
if function_name == 'min' :
195
197
return lnt .util .stats .safe_min
@@ -200,7 +202,7 @@ def determine_aggregation_function(function_name):
200
202
elif function_name == 'median' :
201
203
return lnt .util .stats .median
202
204
else :
203
- assert False , f'Invalid aggregation function name { function_name } '
205
+ return None
204
206
205
207
206
208
@db_route ('/submitRun' , methods = ('GET' , 'POST' ))
@@ -370,7 +372,10 @@ def __init__(self, run_id):
370
372
abort (404 , "Invalid run id {}" .format (run_id ))
371
373
372
374
# Get the aggregation function to use.
373
- aggregation_fn = determine_aggregation_function (request .args .get ('aggregation_function' , 'min' ))
375
+ fn_name = request .args .get ('aggregation_function' , 'min' )
376
+ aggregation_fn = determine_aggregation_function (fn_name )
377
+ if aggregation_fn is None :
378
+ abort (404 , "Invalid aggregation function name {}" .format (fn_name ))
374
379
375
380
# Get the MW confidence level.
376
381
try :
@@ -1197,6 +1202,8 @@ def trace_name(name, test_name, field_name):
1197
1202
1198
1203
fn_name = options .get ('aggregation_function' ) or ('max' if field .bigger_is_better else 'min' )
1199
1204
aggregation_fn = determine_aggregation_function (fn_name )
1205
+ if aggregation_fn is None :
1206
+ abort (404 , "Invalid aggregation function name {}" .format (fn_name ))
1200
1207
agg_value = aggregation_fn (values )
1201
1208
1202
1209
# When aggregating multiple samples, it becomes unclear which sample to use for
0 commit comments