Why are field names in nested snap config becoming strictly enforced for core26?

With newer snapd, I’m seeing a lot of warning like:

  Option value has invalid field name "bios_date". For core26+ snaps, fields must be dash separated
  lowercase alphanumerics.

But, the field name in question is not an actual snap config key name, but from some data nested within a snap config key. This is going to make upgrading some snaps to core26 quite tricky, as it is a breaking change on some cases.

Also, as these warning are generated whenever such config data is updated, it creates a lot of warning messages spam on systems, which are basically just reporting the same thing every time, which seems redundant and noisy.

Given that these field names are in nested data, why is this validation being enforced for core26+ based snaps ? Is there good documentation available on this topic already ?

Thanks!

Cheers,

Just

3 Likes

Hi Justin,

Configuration data is stored as JSON so when you set something like:

$ snap set my-snap 'foo={"bar": "baz"}'

Internally, we store:

{
  "foo": {
    "bar": "baz"
  }
}

Previously, we weren’t applying the same checks to field names that we applied to the key, even though they’re really conceptually the same. This was changed recently to avoid users setting data that contains invalid field names/keys and then can’t be read back. For example:

$ snap set my-snap 'foo={"BAD_KEY": "bar"}'\
# succeeds

But you couldn’t read it back by keying the incorrect name:

$ snap get my-snap foo.BAD_KEY
# error

Which doesn’t make much sense so we now apply the same constraint consistently. If you just want to store the entire JSON object as a string then this still works (note the -s flag on set):

$ snap set my-snap -s 'foo={"BAD_KEY": "bar"}'
$ snap get my-snap foo
{"BAD_KEY": "bar"}

Hope that helps clarify things. Let me know if you have any questions or concerns.

Thanks,

Miguel

Hi @miguelpires ,

Thanks for taking the time to respond :+1:

The logic iseems sound in principle, especially around consistency.

I do think it’s a bit more nuanced than that though in practice from an end users point of view. Not being able to retrieve a key name directly from nested data if it has a bad key name and not being able to retrieve it from nested data directly because it’s part of json string amounts to a similar UX. It’s just that now you can only use one approach, and whereas before you could also just retrieve from the non nested level instead, vs now where you can’t and you need to keep track of what’s a string containing a json object and what’s not [ auto-detecting json is error prone]. Also, it makes the barrier for core26 migration a bit higher, as you likely need to build in migration code to handle it, making it a bit more expensive and risky in practice.

I appreciate that’s not likely to change anything in this regrad, but it’s feedback from an end user none the less :slight_smile:

I do think the snap warnings are potentially over the top however, especially in the current form and with the repetitive nature. One you know, you know, and keep telling me isn’t helping, in fact it’s hindering to some degree.

I don’t recall taking this approach before with other such base snap migration requirements. Perhaps that could be reconsidered ?

Cheers,

Just