{"record":{"id":"6995be3561f8fa39","repo":"jnunemaker/httparty","slug":"self-class-name-has-not-implemented-a-parsing-m","errorCode":null,"errorMessage":"#{self.class.name} has not implemented a parsing method for the #{format.inspect} format.","messagePattern":"#(.+?) has not implemented a parsing method for the #(.+?) format\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"lib/httparty/parser.rb","lineNumber":153,"sourceCode":"    end\n\n    def html\n      body\n    end\n\n    def plain\n      body\n    end\n\n    def supports_format?\n      self.class.supports_format?(format)\n    end\n\n    def parse_supported_format\n      if respond_to?(format, true)\n        send(format)\n      else\n        raise NotImplementedError, \"#{self.class.name} has not implemented a parsing method for the #{format.inspect} format.\"\n      end\n    end\n  end\nend\n","sourceCodeStart":135,"sourceCodeEnd":158,"githubUrl":"https://github.com/jnunemaker/httparty/blob/8f4a09e343b94de9f934f388028ca97620c9b378/lib/httparty/parser.rb#L135-L158","documentation":"The response parser raises NotImplementedError when the request format maps to a method the parser class does not define. parse_supported_format does `send(format)` only if the parser responds_to?(format, true); a custom parser class set via `parser MyParser` that does not inherit HTTParty::Parser (or overrides method_missing-prone APIs without defining json/xml/etc.) triggers this at response-parse time, i.e. after the HTTP call already succeeded.","triggerScenarios":"`parser MyParser` plus `format :json` where MyParser defines neither a class-level call format_from_mimetype nor an instance `json` method; subclassing HTTParty::Parser but renaming or omitting the format methods; a parser that handles only csv while the response Content-Type resolves to :json.","commonSituations":"Writing custom parsers for enveloped APIs (e.g. { data: ..., meta: ... }) and forgetting to define every format the client may request, upgrading httparty where formats like csv were added, and environment-dependent Content-Types (an error page with text/html hitting a JSON-only custom parser).","solutions":["Inherit from HTTParty::Parser and override only what you need, calling super for other formats.","Define the missing method on the custom parser: `def json; JSON.parse(body); end`.","Declare `SupportedFormats` on the custom parser restricted to what it really parses so mismatched Content-Types fall back to plain."],"exampleFix":"# before\nclass EnvelopeParser\n  def self.call(body, _fmt = nil)\n    JSON.parse(body)['data']\n  end\nend\nclass Client\n  include HTTParty\n  parser EnvelopeParser\nend\n# -> NotImplementedError: EnvelopeParser has not implemented a parsing method for the :json format\n\n# after\nclass EnvelopeParser < HTTParty::Parser\n  def json\n    JSON.parse(body)['data']\n  end\nend","handlingStrategy":"validation","validationCode":"class EnvelopeParser < HTTParty::Parser\n  def json; JSON.parse(body)['data']; end\nend\nraise NotImplementedError, 'parser missing json' unless EnvelopeParser.method_defined?(:json)","typeGuard":"parses_format = ->(fmt, klass) { klass.method_defined?(fmt.to_s) }","tryCatchPattern":"begin\n  Client.get(url)\nrescue NotImplementedError => e\n  raise unless e.message.include?('parsing method')\n  Client.get(url, format: :plain).tap { |r| JSON.parse(r.body)['data'] }\nend","preventionTips":["Always subclass HTTParty::Parser for custom parsers so default formats remain available.","Restrict the custom parser's SupportedFormats to what it truly implements.","Spec-test each format your client requests against the custom parser."],"tags":["ruby","httparty","parser","response-parsing","not-implemented","json","xml"],"backgroundTag":"response-parsing-failed","analyzedSha":"8f4a09e343b94de9f934f388028ca97620c9b378","analyzedAt":"2026-08-21T19:30:42.003Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}