Be more forgiving by default with missing registry records?

Most of us have faced this at some point:

  • create an interface with some fields
  • register it on profiles/default/registry.xml
  • install the add-on

Profit :smile: Until here all happy and fine :four_leaf_clover:

Some days/weeks/months later you (or someone from your team) happily adds a new field on that interface, starts again an existing Plone instance, and :boom: the KeyError missing record shows up :scream:

I just got bitten by this :sweat:

So the question is, a KeyError is fine, or should it be a rather big logger.error message rather? :thinking:

On the example above, this means, that whenever we update our website to a newer collective.solr version, all the time between adding the new collective.solr version and adding the record manually (or running an upgrade step), all searches that are powered by Solr are basically broken.

For us, specifically, that means quite a lot of it, as we are heavily using Solr all over our website :sweat_smile:

The solution I came up with for now, is to add an early upgrade step that adds the record before actually updating collective.solr version.

That's far from optimal though:

  • first you need to upgrade twice your system (once to add and run the upgrade step and a second time adding the new collective.solr` version)
  • second it's brittle, as it might be that the interface is still in evolution so you add a new record with its upgrade step, to some time later realize that the name of the field eventually got changed during the review of the feature :confused:

How are you handling this? :thinking: