Type enforcement is broken in a couple of places

There are a couple of commands on the snapcraft CLI that do not do sufficient checks to ensure fields in yaml files are typed correctly:

  • Case 1: When exposing content through a slot in a snap, the content snap is able to export a slot with content being set as a number and this will be accepted. I am not sure what happens to this field as it is supposed to be a string. But when another snap declares a plug to connect to this content, the content field is enforced to be a string, but this enforcement does not happen during build, it happens during store upload checks. This makes it very difficult to debug, specially when the content field is set to a variable like content: 4.5 which is parsed as a number.
  • Case 2: when doing a snapcraft edit-validation-sets the revision field cannot be set as a string i.e. revision: '5', a type error is thrown, so it needs to be set as an integer revision: 5. When running the same edit-validation-sets for the same set, the text editor always shows it as a string revision: '5'. This implies that there is, first an erroneous type check and then a cast of this field. This more than difficult to debug, makes it tedious and confusing.