This issue is closely connected to https://github.com/spring-projects/spring-boot/issues/28130 I think all of the versions that has the fix above (I tested 2.5.6 but 2.6.1 and latest snapshots should behave the same way) prefers OpenMetrics even if the client has a different preference, Examples:

  • Accept: text/plain;version=0.0.4;q=0.3,*/*;q=0.1 -> OpenMetrics
  • Accept: text/plain;version=0.0.4 -> PlainText

This is not incorrect since the first one also accepts */* so it should not complain even if the response is a zip file but it is somewhat unexpected since text/plain is also supported and preferred by the client.

A real life example is Telegraf's Prometheus plugin that does not support OpenMetrics but it accepts */* (incorrectly):

application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3,*/*;q=0.1

Please notice that text/plain is preferred over */*. Because of the above behavior, it will get a response in the OpenMetrics format from Boot and fails because it is not able to process it, see: https://github.com/influxdata/telegraf/issues/10248

Comment From: wilkinsona

Duplicates https://github.com/spring-projects/spring-boot/issues/28446.