Problem/Motivation
When switching between Content and Locale in the /admin/tmgmt/sources/content/node you get an ajax error.
Uncaught AjaxError:
An AJAX HTTP error occurred.
HTTP Result Code: 500
Debugging information follows.
Path: /admin/tmgmt/sources/content/node?ajax_form=1
StatusText: Internal Server Error
ResponseText: {"message":"A fatal error occurred: SQLSTATE[42S22]: Column not found: 1054 Unknown column \u0027e.ajax_form\u0027 in \u0027where clause\u0027: SELECT e.nid AS nid\nFROM \n{node} e\nINNER JOIN {node_field_data} data_table ON data_table.nid = e.nid AND data_table.default_langcode = 1\nWHERE (e.type IN (:db_condition_placeholder_0)) AND (e.ajax_form IN (:db_condition_placeholder_1)) AND (e._wrapper_format IN (:db_condition_placeholder_2)) AND (data_table.langcode IN (:db_condition_placeholder_3, :db_condition_placeholder_4, :db_condition_placeholder_5)) \nORDER BY nid DESC\nLIMIT 20 OFFSET 0; Array\n(\n [:db_condition_placeholder_0] =\u003E translatable_node\n [:db_condition_placeholder_1] =\u003E 1\n [:db_condition_placeholder_2] =\u003E drupal_ajax\n [:db_condition_placeholder_3] =\u003E en\n [:db_condition_placeholder_4] =\u003E de\n [:db_condition_placeholder_5] =\u003E fr\n)\n"}
Steps to Recreate:
1.- visit /admin/tmgmt/sources/content/node.
2.- Select from the dropdown Locale.
3.- Wait until the ajax form loads and gives the error.
Proposed resolution
Check the ajax form post and see any errors for locale.
Remaining tasks
User interface changes

API changes
Data model changes
Original report by [username]
Comments
Comment #1
berdirWe need to whitelist search options in all the places where we dynamically apply conditions:
You can reproduce this in even easier ways:
admin/tmgmt/sources/content/node?whatever=breakit
That will fail. Likely the same for config entities.
Use a whitelist array for all the allowed filter conditions then array_intersect() to limit to those.
Comment #2
juanse254 commentedthis might do it.
Comment #3
berdirToo complicated, just have a hardcoded whitelist, something like protected $conditionFields = [...], add in the dynamic field names while building the form.
Comment #4
juanse254 commentedMaybe this will do it, not uploading interdiff because the approach is totally different.
Comment #6
berdirI don't think this is doing what it should, but you likely did find the correct place.
However, based on what we found, we need to turn this pattern around. So instead of an exclude list, we need to have an include list/whitelist with allowed params and make sure the keys are in that.
Comment #7
juanse254 commentedokay then something like this should do it then.
Comment #8
juanse254 commentedComment #10
berdirSome of those fields are dynamic, specifically the title and bundle filter. it's title for node but name for terms, and it's type for nodes (missing here) but vid for terms.
That's why the tests are failing. See the code in the search form, you need the same logic here. (getKey()).
This can actually be simplified into $search_property_params = array_filter($_GET). While touching this, let's switch to \Drupal::request()->query->all().
Comment #11
berdirOh and... needs tests :)
Just simulate an ajax request by mixing a valid filter argument with a non-valid one and make sure it has been filtered correctly.
Comment #12
juanse254 commentedAdded tests and also updated patch following suggestions.
Comment #15
juanse254 commentedFixed wrong elements in whitelist. Test remains the same.
Comment #16
juanse254 commentedUps, minor changes in coding standards.
Comment #17
LKS90 commented$whitelist[] = $entity->getKey('ENTITY_KEY')is easier to read and does exactly the same in this situation. If you don"t need the return value of array_push (it returns the amount of elements in the array after the push), always use the $array[] way. [See also: http://php.net/manual/en/function.array-push.php#83388]Isn't this switched around? The third parameter is headers, the second is options. The options are used to build the Url.
Comment #18
juanse254 commentedRight on, fixed :). Some standards as well..
Comment #20
berdirThis looks pretty good now, just some minor improvements:
a) The documentation isn't really clear to me. It was weird before and it's worse now. Suggestion:
// Build a list of allowed search conditions and get their values from the request.
Also, I still think we need the same check config entities or do they work differently?
I'd recommend to put this into one of the existing methods. The list tests are already very slow.
The use of $term in the test method is also very confusing, $term is usually a taxonomy term. Just hardcode them into the string, should actually be easier to understand.
Comment #21
juanse254 commentedChanges applied.
P.D: config entities works in a different way.
Comment #23
juanse254 commentedComment #24
berdirYes, better now. Committed.