fleet icon indicating copy to clipboard operation
fleet copied to clipboard

Naming a team "No team" or "All teams" breaks the team

Open noahtalerman opened this issue 1 year ago • 9 comments

Fleet version: Observed in Fleet's dogfood environment (4.55)


💥  Actual behavior

https://www.loom.com/share/74a2395f7bcc4adcb2efdd2d850ba803?sid=41da5122-66c5-4a1f-947e-24447b2c9985

🧑‍💻  Steps to reproduce

  1. Add a team called "No team"
  2. Click on the new team
  3. Try to filter hosts by the new team

🕯️ More info (optional)

@noahtalerman: I don't think we considered this case when introducing the concept of "No teams" or "All teams"

🛠️ To fix

Add validation and an easy to understand error message when the user is creating (or updating) a team via UI, API, or GitOps w/ the name of "No team" or "All teams"

  • Ignore capitalization: If "aLL teAmS" is specified, error when the user tries to create a team. Same for "nO TeaM"

If "aLL teAmS" or "nO TeaM" is specified in volume_purchasing_program key in GitOps YAML, error because this is a non existent team. The user must specify "All teams" or "No team" (correct capitalization).

noahtalerman avatar Aug 12 '24 23:08 noahtalerman

Hey @getvictor I just ran into this.

Is there anything tricky / something I'm missing w/ the proposed solution?

Do other apps behave like this?

noahtalerman avatar Aug 12 '24 23:08 noahtalerman

Do other apps behave like this?

@marko-lisica have you seen apps reserve names? What are some examples?

noahtalerman avatar Aug 12 '24 23:08 noahtalerman

Hey @getvictor I just ran into this.

Is there anything tricky / something I'm missing w/ the proposed solution?

Do other apps behave like this?

From looking at the code, the backend supports these team names. I'm guessing it is the frontend that's breaking.

That said, we can add a validation to not allow these names (with this specific capitalization).

getvictor avatar Aug 13 '24 06:08 getvictor

Do other apps behave like this?

@marko-lisica have you seen apps reserve names? What are some examples?

@noahtalerman Gmail is doing a similar thing. If you want to create label, you can't use word "Inbox", because they have system labels.

Off topic: Seems that we prevent users from creating label with names that already exist, but we don't prevent them from creating labels with names of system labels (Windows, macOS, Linux, etc.)

Screenshot 2024-08-13 at 10 05 20 Screenshot 2024-08-13 at 09 59 25 Screenshot 2024-08-13 at 10 05 34

marko-lisica avatar Aug 13 '24 08:08 marko-lisica

we don't prevent them from creating labels with names of system labels (Windows, macOS, Linux, etc.)

@marko-lisica hmm, seems like we should. What happens when you do this? Do certain features break?

noahtalerman avatar Aug 13 '24 16:08 noahtalerman

we don't prevent them from creating labels with names of system labels (Windows, macOS, Linux, etc.)

@marko-lisica hmm, seems like we should. What happens when you do this? Do certain features break?

@noahtalerman I'm not sure what could break. The only thing that comes to my mind is that a label is assigned by name to a profile (in GitOps). In case where exist two labels with the same name (Fleet system label and custom label) which one will be attached to a profile?

marko-lisica avatar Aug 13 '24 17:08 marko-lisica

Thanks @marko-lisica. When you get the chance, can you please track a separate bug for adding validation/errors for built-in labels?

noahtalerman avatar Aug 13 '24 21:08 noahtalerman

Moved to MDM per @noahtalerman's request.

sharon-fdm avatar Aug 14 '24 18:08 sharon-fdm

Heads-up that we should also apply this validation when updating the team's name. I'll mention it in the "To fix" section.

mna avatar Aug 19 '24 12:08 mna

QA Notes: API and GitOps errors look good when trying to create no team or all teams

~/fleetdm/fleet main ❯ ./build/fleetctl gitops -f  ~/fleetdm/gitops/teamTest.yaml                                                   11s 10:56:49 AM
Error: applying teams: POST /api/latest/fleet/spec/teams received status 422 Validation Failed: "No team" is a reserved team name
~/fleetdm/fleet main ❯ ./build/fleetctl gitops -f  ~/fleetdm/gitops/teamTest.yaml                                                       10:56:52 AM
Error: applying teams: POST /api/latest/fleet/spec/teams received status 422 Validation Failed: "All teams" is a reserved team name

However in the UI we get a generic error. I think it would make sense for the Toast to show the same user friendly error. Do you agree @noahtalerman ? Screenshot 2024-09-09 at 10 55 01 AM

PezHub avatar Sep 09 '24 18:09 PezHub

QA Notes: 🐛 to fix the above error message https://github.com/fleetdm/fleet/issues/21971

PezHub avatar Sep 10 '24 22:09 PezHub

QA Notes:

confirmed I cannot create new teams with either name and the bug fix improves the error message and Screenshot 2024-09-13 at 8 39 43 AM adds validation. Screenshot 2024-09-13 at 8 39 21 AM

PezHub avatar Sep 13 '24 15:09 PezHub

"No team" or "All", Validation brings clarity, Fleet flows, no fall.

fleet-release avatar Sep 24 '24 00:09 fleet-release