code: def clean_helper(B, obj, clean_func):
      
      try:
          clean_func(obj)
      except B.validation_error() as e:
          # _debug.log_validation_errors(B, e, obj, k)
  
          # Check if it's a uniqueness or missing relation error
          fields = B.detect_uniqueness_error(e)
          missing = B.detect_missing_relations(obj, e)
          return fields, missing
      return (None, None)
docs: Clean object, intercepting and collecting any missing-relation or
      unique-constraint errors and returning the relevant resource ids/fields.
  
      Returns:
          - tuple: (<dict of non-unique fields>, <dict of missing refs>)