docs: def process_custom_field(connection, project_id, cf_type, cf_name, value_names=None):
      """
      Creates custom field and attaches it to the project. If custom field already exists and has type
      cf_type it is attached to the project. If it has another type, LogicException is raised. If project field already
      exists, uses it and bundle from it. If not, creates project field and bundle with name
      <cf_name>_bundle_<project_id> for it.
      Adds value_names to bundle.
      Args:
          connection: An opened Connection instance.
          project_id: Id of the project to attach CF to.
          cf_type: Type of cf to be created.
          cf_name: Name of cf that should be created (if not exists) and attached to the project (if not yet attached)
          value_names: Values, that cf must have. If None, does not create any bundle for the field. If empty list,
                       creates bundle, but does not create any value_names in it. If bundle already contains
                       some value_names, only value_names that do not already exist are added.
  
      Raises:
          LogicException: If custom field already exists, but has wrong type.
          YouTrackException: If something is wrong with queries.
      """
  
      _create_custom_field_prototype(connection, cf_type, cf_name)
      if cf_type[0:-3] not in connection.bundle_types:
          value_names = None
      elif value_names is None:
          value_names = []
  
      existing_project_fields = [item for item in connection.getProjectCustomFields(project_id) if
                                 utf8encode(item.name) == cf_name]
      if len(existing_project_fields):
          if value_names is None:
              return
          bundle = connection.getBundle(cf_type, existing_project_fields[0].bundle)
          values_to_add = calculate_missing_value_names(bundle, value_names)
      else:
          if value_names is None:
              connection.createProjectCustomFieldDetailed(project_id, cf_name, "No " + cf_name)
              return
          bundle = create_bundle_safe(connection, cf_name + "_bundle_" + project_id, cf_type)
          values_to_add = calculate_missing_value_names(bundle, value_names)
          connection.createProjectCustomFieldDetailed(project_id, cf_name, "No " + cf_name,
                                                      params={"bundle": bundle.name})
      for name in values_to_add:
          connection.addValueToBundle(bundle, bundle.createElement(name))