It was possible for an enum field lookup to return an empty list. This meant there were no options for the list.
We now test for this and raise an error.
This commit is contained in:
parent
329146237e
commit
b42b843f7d
|
@ -316,7 +316,11 @@ class WorkflowService(object):
|
||||||
data = db.session.query(LookupDataModel).filter(
|
data = db.session.query(LookupDataModel).filter(
|
||||||
LookupDataModel.lookup_file_model == lookup_model).limit(10).all()
|
LookupDataModel.lookup_file_model == lookup_model).limit(10).all()
|
||||||
options = [{"value": d.value, "label": d.label, "data": d.data} for d in data]
|
options = [{"value": d.value, "label": d.label, "data": d.data} for d in data]
|
||||||
return random.choice(options)
|
if len(options) > 0:
|
||||||
|
return random.choice(options)
|
||||||
|
else:
|
||||||
|
raise ApiError.from_task("invalid enum", "You specified an enumeration field (%s),"
|
||||||
|
" with no options" % field.id, task)
|
||||||
else:
|
else:
|
||||||
raise ApiError.from_task("unknown_lookup_option", "The settings for this auto complete field "
|
raise ApiError.from_task("unknown_lookup_option", "The settings for this auto complete field "
|
||||||
"are incorrect: %s " % field.id, task)
|
"are incorrect: %s " % field.id, task)
|
||||||
|
|
Loading…
Reference in New Issue