{"record":{"id":"2307c336f884dec3","repo":"puppetlabs/puppet","slug":"content-type-is-unsupported","errorCode":null,"errorMessage":"Content-Type is unsupported","messagePattern":"Content-Type is unsupported","errorType":"exception","errorClass":"Puppet::HTTP::ProtocolError","httpStatus":null,"severity":"error","filePath":"lib/puppet/http/service.rb","lineNumber":137,"sourceCode":"  def build_url(api, server, port)\n    URI::HTTPS.build(host: server,\n                     port: port,\n                     path: api).freeze\n  end\n\n  def get_mime_types(model)\n    network_formats = model.supported_formats - EXCLUDED_FORMATS\n    network_formats.map { |f| model.get_format(f).mime }\n  end\n\n  def formatter_for_response(response)\n    header = response['Content-Type']\n    raise Puppet::HTTP::ProtocolError, _(\"No content type in http response; cannot parse\") unless header\n\n    header.gsub!(/\\s*;.*$/, '') # strip any charset\n\n    formatter = Puppet::Network::FormatHandler.mime(header)\n    raise Puppet::HTTP::ProtocolError, \"Content-Type is unsupported\" if EXCLUDED_FORMATS.include?(formatter.name)\n\n    formatter\n  end\n\n  def serialize(formatter, object)\n    formatter.render(object)\n  rescue => err\n    raise Puppet::HTTP::SerializationError.new(\"Failed to serialize #{object.class} to #{formatter.name}: #{err.message}\", err)\n  end\n\n  def serialize_multiple(formatter, object)\n    formatter.render_multiple(object)\n  rescue => err\n    raise Puppet::HTTP::SerializationError.new(\"Failed to serialize multiple #{object.class} to #{formatter.name}: #{err.message}\", err)\n  end\n\n  def deserialize(response, model)\n    formatter = formatter_for_response(response)","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/puppetlabs/puppet/blob/e227c27540975c25aa22d533a52424a9d2fc886a/lib/puppet/http/service.rb#L119-L155","documentation":"After resolving a formatter from Content-Type, Puppet::HTTP::Service rejects formats that are excluded from network use: EXCLUDED_FORMATS = [:yaml, :b64_zlib_yaml, :dot] (service.rb:15). Those renderers exist only for local CLI output, so a response advertising e.g. text/yaml or the b64_zlib_yaml/dot mimes raises Puppet::HTTP::ProtocolError — puppet's HTTP services only negotiate pson/json (and msgpack when enabled).","triggerScenarios":"A server responds with a Content-Type that FormatHandler maps to :yaml, :b64_zlib_yaml, or :dot — e.g. someone force-enabling YAML serialization on puppetserver routes, or a proxy rewriting Content-Type; version/feature skew where one side negotiates a format the other never accepts over HTTP.","commonSituations":"Operators configuring preferred_serialization_format or format whitelists to yaml thinking it is network-safe; middleboxes 'normalizing' application/json to text/yaml; mismatched agent/server pairs after a partial upgrade.","solutions":["Set both agent and server to a network-supported format (pson/json, or msgpack via the proper setting) and remove yaml from route format lists.","Remove any proxy rule that rewrites response Content-Type.","Align agent and server versions so format negotiation matches."],"exampleFix":"# puppetserver conf (route) - before\nprovides: [yaml, pson]\n\n# after - yaml is not a network format\nprovides: [pson, json]","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"begin\n  service.get_facts(name)\nrescue Puppet::HTTP::ProtocolError => e\n  raise unless e.message.include?('Content-Type is unsupported')\n  # server advertised yaml/b64_zlib_yaml/dot — fix route format negotiation\n  raise\nend","preventionTips":["Never advertise yaml, b64_zlib_yaml, or dot as network formats on puppetserver routes.","Keep preferred_serialization_format consistent (pson/json, or msgpack deliberately enabled).","Align agent and server versions so format negotiation cannot skew."],"tags":["puppet","http","content-type","serialization-formats","protocol"],"backgroundTag":"unsupported-content-type","analyzedSha":"e227c27540975c25aa22d533a52424a9d2fc886a","analyzedAt":"2026-08-21T20:49:46.650Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}