def GetInvalidTypeErrors(type_names, metrics):
  """Check that all of the metrics have valid types.

  Args:
    type_names: The set of valid type names.
    metrics: A list of rappor metric description objects.

  Returns:
    A list of errors about metrics with invalid_types.
  """
  invalid_types = [m for m in metrics if m['type'] not in type_names]
  return ['Rappor metric "%s" has invalid type "%s"' % (
              metric['name'], metric['type'])
          for metric in invalid_types]