Bug #38076
closedThe content view APIs will pass repository_ids to the code both as a list of int or a list of strings
Description
This is a problem, because https://github.com/Katello/katello/blob/master/app/lib/actions/katello/content_view/update.rb
performs set difference logic as follows:
repo_ids_to_remove = content_view.repository_ids - content_view_params[:repository_ids]
Here, content_view.repository_ids is taken from the DB and is always a list of integers.
content_view_params[:repository_ids] is passed in from the API and is sometimes a list of strings.
When the types diverge, the set difference logic breaks down.
The only reason this does not lead to noticeably buggy behaviour, is because the result of the set logic is only used to determine whether or not to enter an if block.
However, for rolling content views (https://projects.theforeman.org/issues/38048), we want to use identical logic and directly use the resulting lists.
We could fix this within the app/lib/actions/katello/content_view/update.rb action, but we think it makes more sense for the API to send consistently typed data to the backend.
Our proposal is to always cast the data received by the API from the user to a list of integers in the API controller.
PR will follow shortly.