"Points are no planar" error message when creating a face

Thanks for the recommendations. I tried to change the code of the create_groove function. Unfortunately I get the non-coplanar points error again. Here’s what I changed:

def create_groove
  model = Sketchup.active_model
  model.start_operation("Create Groove", true)

  edge_vector = @selected_edge.line[1].normalize
  offset_vector = @selected_face.normal * edge_vector
  offset_vector.length = @groove_offset

  # Checking if an offset point lies on a face
  test_point = @selected_edge.start.position.offset(offset_vector)
  if @selected_face.classify_point(test_point) != Sketchup::Face::PointInside
    offset_vector.reverse!
  end

  # Apply offset to create groove start points
  offset_start_point = @selected_edge.start.position.offset(offset_vector)
  offset_end_point = @selected_edge.end.position.offset(offset_vector)

  # Determination of additional points for forming the width of the groove
  edge_vector.length = @groove_width
  point3 = offset_end_point.offset(edge_vector)
  point4 = offset_start_point.offset(edge_vector)

  # Creating a face directly from points on the parent entities of the selected face
  begin
    new_face = @selected_face.parent.entities.add_face(offset_start_point, offset_end_point, point3, point4)
    new_face.pushpull(-@groove_depth, true) if new_face.valid?
  rescue ArgumentError => e
    UI.messagebox("Error creating groove: #{e.message}")
  ensure
    model.commit_operation
  end
end