1) Use the function module COM_SETTYPE_ATTR_DELETE to delete the attribute from the set type
Note that the attribute will not be deleted from the database table how ever.
2) Debug the code for regenerating the set type (take the help of a developer if needed) put a break point where the error actually occurs.
3) Avoid the error of deletion from regenerating the set type once the set type has been regenerated your attribute will be deleted from the DB table also.
4) Then you can edit the attribute and assign it to the set type again or delete and create a new one.
Hope this helps for any 1 in need