{"record":{"id":"f648487ccb2a69b4","repo":"jnunemaker/httparty","slug":"deprecation-httparty-will-no-longer-override-re","errorCode":null,"errorMessage":"[DEPRECATION] HTTParty will no longer override `response#nil?`. This functionality will be removed in future versions. Please, add explicit check `response.body.nil? || response.body.empty?`. For more info refer to: https://github.com/jnunemaker/httparty/issues/568\n#{trace_line}","messagePattern":"\\[DEPRECATION\\] HTTParty will no longer override `response#nil\\?`\\. This functionality will be removed in future versions\\. Please, add explicit check `response\\.body\\.nil\\? \\|\\| response\\.body\\.empty\\?`\\. For more info refer to: https://github\\.com/jnunemaker/httparty/issues/568\n#(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/httparty/response.rb","lineNumber":151,"sourceCode":"    end\n\n    def throw_exception\n      if @request.options[:raise_on].to_a.detect { |c| code.to_s.match(/#{c.to_s}/) }\n        ::Kernel.raise ::HTTParty::ResponseError.new(@response), \"Code #{code} - #{body}\"\n      end\n    end\n\n    private\n\n    def warn_about_nil_deprecation\n      trace_line = caller.reject { |line| line.include?('httparty') }.first\n      warning = \"[DEPRECATION] HTTParty will no longer override `response#nil?`. \" \\\n        \"This functionality will be removed in future versions. \" \\\n        \"Please, add explicit check `response.body.nil? || response.body.empty?`. \" \\\n        \"For more info refer to: https://github.com/jnunemaker/httparty/issues/568\\n\" \\\n        \"#{trace_line}\"\n\n      warn(warning)\n    end\n  end\nend\n\nrequire 'httparty/response/headers'\n","sourceCodeStart":133,"sourceCodeEnd":157,"githubUrl":"https://github.com/jnunemaker/httparty/blob/8f4a09e343b94de9f934f388028ca97620c9b378/lib/httparty/response.rb#L133-L157","documentation":"This is not an exception but a deprecation warning printed (via Kernel#warn, including the caller's trace line) whenever HTTParty::Response#nil? is invoked. Response#nil? historically returned true for empty bodies, which conflates 'no response' with 'empty body'; httparty will stop overriding nil?, so the warning tells you to replace `response.nil?` checks with an explicit `response.body.nil? || response.body.empty?` before upgrading. Once the override is removed, truthy Response objects will behave like normal Ruby objects under nil checks.","triggerScenarios":"Any code doing `if resp.nil?`, `unless response`, `resp || default`, or `Array.wrap(response)` on an HTTParty::Response whose body is nil or empty — including `puts resp` style debugging that goes through nil? indirectly.","commonSituations":"Long-lived codebases from the httparty era where `response.nil?` was the idiomatic empty-body check, boolean coercion in templates or presenters, and gems that call .nil? on arbitrary objects (serializers, loggers) now triggering noisy warnings against httparty responses.","solutions":["Replace `response.nil?` with `response.body.nil? || response.body.empty?` (the exact check the message prescribes).","Wrap the intent in a helper: `def empty_response?(r) = r.body.nil? || r.body.empty?` and use it everywhere.","After migrating, upgrade httparty and confirm the warning no longer appears in logs."],"exampleFix":"# before\nresp = Api.get('/jobs')\nreturn [] if resp.nil?          # triggers DEPRECATION warning\n\n# after\nresp = Api.get('/jobs')\nreturn [] if resp.body.nil? || resp.body.empty?","handlingStrategy":"validation","validationCode":"def empty_response?(resp)\n  resp.body.nil? || resp.body.empty?\nend\n\nreturn [] if empty_response?(Api.get('/jobs'))","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grep the codebase for `.nil?`/`||=`/`unless` applied to httparty responses and replace with explicit body checks.","Centralize empty-body logic in one helper so the eventual upgrade is a one-line change.","Run the test suite with warnings visible after each httparty upgrade to catch newly deprecated idioms."],"tags":["ruby","httparty","deprecation","response","nil-handling","upgrade"],"backgroundTag":"deprecated-api-usage","analyzedSha":"8f4a09e343b94de9f934f388028ca97620c9b378","analyzedAt":"2026-08-21T19:30:42.003Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}