{"record":{"id":"c045bb2d1ce27e41","repo":"jnunemaker/httparty","slug":"format-inspect-must-be-one-of-supported-fo","errorCode":null,"errorMessage":"'#{format.inspect}' Must be one of: #{supported_format_names}","messagePattern":"'#(.+?)' Must be one of: #(.+?)","errorType":"exception","errorClass":"HTTParty::UnsupportedFormat","httpStatus":null,"severity":"error","filePath":"lib/httparty.rb","lineNumber":633,"sourceCode":"      unless options.key?(:maintain_method_across_redirects)\n        options[:maintain_method_across_redirects] = true\n      end\n    end\n\n    def perform_request(http_method, path, options, &block) #:nodoc:\n      build_request(http_method, path, options).perform(&block)\n    end\n\n    def process_cookies(options) #:nodoc:\n      return unless options[:cookies] || default_cookies.any?\n      options[:headers] ||= headers.dup\n      options[:headers]['cookie'] = cookies.merge(options.delete(:cookies) || {}).to_cookie_string\n    end\n\n    def validate_format\n      if format && parser.respond_to?(:supports_format?) && !parser.supports_format?(format)\n        supported_format_names = parser.supported_formats.map(&:to_s).sort.join(', ')\n        raise UnsupportedFormat, \"'#{format.inspect}' Must be one of: #{supported_format_names}\"\n      end\n    end\n  end\n\n  def self.normalize_base_uri(url) #:nodoc:\n    normalized_url = url.dup\n    use_ssl = (normalized_url =~ /^https/) || (normalized_url =~ /:443\\b/)\n    ends_with_slash = normalized_url =~ /\\/$/\n\n    normalized_url.chop! if ends_with_slash\n    normalized_url.gsub!(/^https?:\\/\\//i, '')\n\n    \"http#{'s' if use_ssl}://#{normalized_url}\"\n  end\n\n  class Basement #:nodoc:\n    include HTTParty\n  end","sourceCodeStart":615,"sourceCodeEnd":651,"githubUrl":"https://github.com/jnunemaker/httparty/blob/8f4a09e343b94de9f934f388028ca97620c9b378/lib/httparty.rb#L615-L651","documentation":"HTTParty raises UnsupportedFormat when the format set via `format :xyz` is not one of the formats the configured parser supports. validate_format runs when the format DSL is used: it checks parser.supports_format?(format) when the parser responds to that class method, and lists the supported names in the message. The default parser supports the formats mapped in HTTParty::Parser::SupportedFormats (json, xml, html, plain, csv, atom, rss and related mime-mapped names).","triggerScenarios":"`format :msgpack` or `format :xlsx` with the default parser inside an HTTParty class; also when a custom parser class defines SupportedFormats without including the format later set via `format :json`.","commonSituations":"Consuming APIs that return MessagePack, protobuf or other non-default content, upgrading httparty and hitting stricter validation, or setting a format symbol that only exists after a custom parser is wired up in the wrong order.","solutions":["Check what is supported: `HTTParty::Parser.supported_formats.inspect` and use one of those symbols.","For custom formats, subclass HTTParty::Parser, add to SupportedFormats and define the method, then `parser MyParser` before `format :msgpack`.","If the body is a non-standard format, skip `format` entirely and parse response.body manually."],"exampleFix":"# before\nclass Client\n  include HTTParty\n  format :msgpack   # UnsupportedFormat\nend\n\n# after\nrequire 'msgpack'\nclass MsgpackParser < HTTParty::Parser\n  SupportedFormats.update({ 'application/msgpack' => :msgpack })\n  def msgpack\n    MessagePack.unpack(body)\n  end\nend\n\nclass Client\n  include HTTParty\n  parser MsgpackParser\n  format :msgpack\nend","handlingStrategy":"validation","validationCode":"fmt = :msgpack\nunless (parser_class || HTTParty::Parser).supports_format?(fmt)\n  raise HTTParty::UnsupportedFormat, \"#{fmt} not supported by #{parser_class || HTTParty::Parser}\"\nend","typeGuard":"supported = ->(fmt) { HTTParty::Parser.supported_formats.map(&:to_s).include?(fmt.to_s) }","tryCatchPattern":"begin\n  format fmt\nrescue HTTParty::UnsupportedFormat\n  parser MyParserWithFmt  # defines the format first\n  format fmt\nend","preventionTips":["Check HTTParty::Parser.supported_formats before adopting a new format symbol.","Wire the custom parser (`parser X`) before setting `format`.","Cover custom formats with a smoke spec that performs one request."],"tags":["ruby","httparty","configuration","validation","response-format","parser"],"backgroundTag":"unsupported-format","analyzedSha":"8f4a09e343b94de9f934f388028ca97620c9b378","analyzedAt":"2026-08-21T19:30:42.003Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}