• Mike Lang's avatar
    Replace 'none' id for the none option in union types with '' · 383ace4d
    Mike Lang authored
    In union option groups, the list of selected ids is encoded as a comma-delimited string.
    For example, if 'foo' and 'bar' are selected, the value 'foo,bar' is sent, ie ["foo", "bar"] -> "foo,bar"
    Under this scheme, with nothing selected, the empty string should be sent, ie. [] -> ""
    
    Before this change, the frontend code called the "none option" by id 'none'.
    There were several issues with this:
    * The frontend would send 'none' when nothing was selected, not ''. The backend ignored this as it ignores
      junk values in the options, treating them as though they hadn't been given.
    * The backend would attempt to set the default value of an option to "nothing selected", ie. [], by sending ''.
      The frontend would interpret this as nothing selected, *not even the 'none' option*, which caused a visual bug.
    * Everything would break if one of the legitimate options had the id 'none', which could easily happen eg.
      if a user had a 'none' k8s namespace. This is perhaps an unusual name, but our code shouldn't break when
      a particular arbitary string is used as an input.
    
    With this change, the none option is called '', which fixes all the above problems:
    * The frontend encodes [''] as ''
    * The frontend decodes '' as [''], and therefore shows the '' option as selected
    * The string '' is not a valid k8s namespace name and is a reasonable "prohibited value" for all other use cases.
      The backend already couldn't handle a value with this id correctly prior to this change anyway.
    383ace4d