Problem:
When sending POST request to /api/users/:user_id/table_preferences the total number of preferences doesn’t not change thus breaking future PUT or DELETE requests.
How to reproduce:
- Create new table_preference for the user with 0 preferences using POST request /api/users/:user_id/table_preferences with the following body:
{
"name": "hosts",
"columns": [
"power_status",
"name"
]
}
(was done by user from UI on All Hosts tab in Foreman.)
2. Fetch info with GET /api/users/:user_id/table_preferences.
Expected outcome:
Response of GET request contains “total”: 1 and “subtotal”: 1
{
"total": 1,
"subtotal": 1,
"page": 1,
"per_page": 50,
"search": null,
"sort": {
"by": null,
"order": null
},
"results": [
{
"id": 8,
"name": "hosts",
"columns": [
"power_status",
"name"
],
"created_at": "2023-07-13 08:27:59 UTC",
"updated_at": "2023-08-24 11:23:34 UTC"
}
]
}
Actual outcome:
Response of GET request contains “total”: 0 and “subtotal”: 0
{
"total": 0,
"subtotal": 0,
"page": 1,
"per_page": 50,
"search": null,
"sort": {
"by": null,
"order": null
},
"results": [
{
"id": 8,
"name": "hosts",
"columns": [
"power_status",
"name"
],
"created_at": "2023-07-13 08:27:59 UTC",
"updated_at": "2023-08-24 11:23:34 UTC"
}
]
}
Foreman version:
v. 3.6.1
Other relevant data:
Future PUT and DELETE requests to /api/users/:user_id/table_preferences/hosts are not working with the following error:
"error": {"message": "Resource table_preference not found by id 'hosts' "}
That maybe entirely different issue or a cause of this problem. I’ve searched community and foreman issue tracker and didn’t find anything like this so I raised this question for it. Could you please advise on how to edit existing user records because some of them have all of the preferences selected on Hosts tab (making it unusable) and we can’t change it back.