I have a custom field set that is used for cases of a certain case type. Adding a second case type brings up the following popup after saving:
Warning: You have chosen to remove one or more subtypes. This will cause any custom data records associated with those subtypes to be removed as long as the contact does not have a contact subtype still selected.
Confirming it throws the exception:
CRM_Core_Exception: Supplied Sub type is not valid for the specified entity in /opt/drupal/vendor/civicrm/civicrm-core/CRM/Custom/Form/Group.php on line 293
If I do the same on a custom field set for contacts it's fine, When creating a new custom field set for cases and adding the two case types I can save it but when trying to open it again this exception occurs:
CRM_Core_Exception: Expected to find one CustomGroup record, but there were zero. in /opt/drupal/vendor/civicrm/civicrm-core/Civi/Api4/Generic/Result.php on line 90
Seems to me that Civi thinks we are dealing with custom data for contacts here.
I am on CiviCRM version 5.70.0.