fleetdm / fleet

Open-source platform for IT, security, and infrastructure teams. (Linux, macOS, Chrome, Windows, cloud, data center)
https://fleetdm.com
Other
3.12k stars 431 forks source link

Show pending payload when MDM command is in pending status #20816

Open gillespi314 opened 3 months ago

gillespi314 commented 3 months ago

When attempting to view install details for a pending VPP app install, the UI will display an error even though the API response returns successfully.

Screenshot 2024-07-29 at 1 21 41 PM

More info:

We have any specs for what the GET /commands/results?command_uuid=:command_uuid API response should be where the command exists but we don't have results yet.

This oversight is most likely because this endpoint goes all the way back to the original POC for MDM and was until now only really used by the CLI.

Up to now, it didn’t matter, because our struct for the response type make the fleetctl client think that there is a results field present with the default value even if the body was {}. So the client just displayed an empty table in that case.

There are two ways we could tackle this:

  1. Add { results: [] } to the JSON response body (which mirrors what the CLI client implicitly does in this case) and leave it to the frontend to piece together the other info it needs to display the pending UI.
  2. Respond with as much info as we have when the command_uuid exists but there are no results yet. This would mean we need to revisit what the CLI displays in this case.

If we go with option 2, we’d need to decide what to return for status, updated_at and result, I think. Here’s the shape expected where there are results.

{
  "results": [
    {
      "host_uuid": "145cafeb-87c7-4869-84d5-e4118a927746",
      "command_uuid": "a2064cef-0000-1234-afb9-283e3c1d487e",
      "status": "Acknowledged",
      "updated_at": "2023-04-04:00:00Z",
      "request_type": "ProfileList",
      "hostname": "mycomputer",
      "payload": "<<BASE_64_ENCODED_STRING>>",
      "result": "<<BASE_64_ENCODED_STRING>>"
    }
  ]
}

Note that status for this API endpoint has historically been the raw status from Apple (i.e., “Acknowledged”, “NotNow”, etc.) rather than Fleet’s derived status (e.g., “Pending”). For updated_at and result, we’d need to decide on whether we want the default value to be empty strings or something else.

Thanks to @mostlikelee for raising this issue in Slack.

roperzh commented 3 months ago

@marko-lisica to sort the API out and get back to @gillespi314

noahtalerman commented 3 months ago

Hey @georgekarrv and @gillespi314 during design review yesterday we decided to push adding the payload for pending MDM commands in the UI/API. The Figma is updated here.

Instead we're tracking this addition is this issue as a follow up story for later.

I removed the :release and 4.46.0-tentative milestone. Please let me know if y'all have a different understanding.

FYI @getvictor and @jacobshandling because y'all are working on the iOS/iPadOS App Store app story.

noahtalerman commented 3 months ago

Also, @gillespi314, my understanding is that we're still shipping the UI/API changes for NotNow response as shown in Figma here).

Is that right?

roperzh commented 3 months ago

@noahtalerman @gillespi314 I think we need to create a separate, ~unreleased-bug to fix the UI then! right now the user will see an error message

I created https://github.com/fleetdm/fleet/issues/20937

noahtalerman commented 3 months ago

Thanks @roperzh!