How to avoid "An illegal choice has been detected" when updating select list values via ajax?
--- Original answer. Is wrong, check update below.

Just set 

$bla['#validated'] = TRUE


On the select that will be updated with AJAX.

Checkout &quot;Illegal Choice has been detected&quot;

--- Update 17 Dec 2019 ---

Actually that was not good advice, that was a long time ago, now I know better.

Ajax callback function is supposed to only return the piece of form that has changed or some ajax commands.

In this case form modification must be made on the form function or a form alter hook. Form building and validation functions are run each time an ajax callback is called. Just check $form_state on your form build or alter function and adjust values accordingly.

See Resolve the error &quot;An illegal choice has been detected...&quot;