fleet icon indicating copy to clipboard operation
fleet copied to clipboard

[FleetUI] All hosts transferred to "No Team" after using "Select all matching hosts" with filters applied

Open ksatter opened this issue 1 year ago • 5 comments

Fleet version: v4.44.1


💥  Actual behavior

When attempting to transfer all hosts out of a team with more than 50 hosts, all hosts were transferred instead of only the hosts in the original team.

The customer filtered the Hosts view by the team hosts were being transferred from, and then used the check box to select all hosts on the page, then "Select all matching hosts" and transferred selected hosts to "No Team".

After the transfer was complete, all hosts had been transferred rather than the expected host count displayed in the UI for matching hosts.

When the transfer was complete

🧑‍💻  Steps to reproduce

  1. TODO
  2. TODO

🕯️ More info (optional)

ksatter avatar Feb 17 '24 01:02 ksatter

Reproduced in my local environment. This bug triggers when, due to the host count exceeding the 50 per page display, the user selects "select all matching hosts.:

Screenshot 2024-02-20 at 10 20 56 AM

As an additional test, I verified this behavior does not apply to the Delete action.

sabrinabuckets avatar Feb 20 '24 15:02 sabrinabuckets

Ok, looking into this, the select all hosts is hitting the transfer hosts to a team by filter endpoint. That endpoint doesn't have a filter option for team, only status, query, and label. https://fleetdm.com/docs/rest-api/rest-api#transfer-hosts-to-a-team-by-filter

I believe this should be reconsidered as a backend bug as we should still use this API end point, but the fix on the backend would be to take in current team ID as one of the filters for `hosts/transfer/filter

Need backend folk to confirm. Maybe @lucasmrod @getvictor or @gillespi314 ?

RachelElysia avatar Feb 20 '24 21:02 RachelElysia

Also, since that API only transfers on those parameters, what happens if you try to click "select all hosts" for something like all hosts failing a policy? Wouldn't that also be buggy?

RachelElysia avatar Feb 20 '24 21:02 RachelElysia

Also, since that API only transfers on those parameters, what happens if you try to click "select all hosts" for something like all hosts failing a policy? Wouldn't that also be buggy?

Yes, I think so. Looks like the backend essentially ignores any fields included in the request that are not expressly specified.

gillespi314 avatar Feb 20 '24 21:02 gillespi314

Yes, backend should be able to filter by team_id. I'm not sure how to select all hosts failing a policy -- that's not an option I see.

getvictor avatar Feb 20 '24 22:02 getvictor

I couldn't think of a haiku this time. (See fleetdm.com logs for more information.)

fleet-release avatar Mar 12 '24 23:03 fleet-release