Skip to content

Add HTTPService::Response#raw_body with the unparsed response - #328

Open
jjb wants to merge 1 commit into
maxmind:mainfrom
jjb:response-raw-body
Open

jjb wants to merge 1 commit into
maxmind:mainfrom
jjb:response-raw-body

Conversation

@jjb

@jjb jjb commented Nov 14, 2026 •

Copy link
Copy Markdown

This adds raw_body to Minfraud::HTTPService::Response: the response body as the web service sent it, before parsing.

The models are a good way to read a response. But a user who wants to store the response, log it, or read a field the library doesn't model yet has no public way to get the response itself. The client reads the body, parses it into a model and discards it.

raw_body gives the response exactly as received, and leaves parsing and storage to the caller. A stored body can still become a model with Minfraud::Model::Factors.new(JSON.parse(raw_body), ['en']).

It's a String rather than the HTTP::Response, so the public API doesn't depend on the HTTP library.

The successful-request example in spec/http_spec.rb now also checks raw_body. bundle exec rspec (263 examples) and RuboCop pass. The CHANGELOG entry is under the unreleased v2.11.0.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • HTTP responses now provide access to the original, unparsed response body. This makes the complete response available for storage or logging, including fields not represented in the library’s parsed response, while preserving access to the parsed response as before.

The client parsed the response body into a model and discarded it, so there
was no public way to store or log a response as received, or to read a field
the models don't cover yet. raw_body is the body string before parsing.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 14, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Minfraud::HTTPService::Response now exposes the original response body through raw_body, alongside the parsed response model. The HTTP spec checks both the parsed risk_score and the original JSON body. The v2.11.0 changelog documents the new reader.

Changes: HTTP response body

Layer / File(s) Summary
Expose and verify the raw body
lib/minfraud/http_service/response.rb, spec/http_spec.rb, CHANGELOG.md
Response stores the original body in raw_body alongside the HTTP status. The spec checks the parsed risk_score and original JSON body. The changelog documents raw_body.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Feature

Suggested reviewers: horgh

Merge Risk: Minimal · up to ee320

This adds a read-only accessor for the original response body, with a test and changelog entry. Existing behavior is unchanged, and no merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: adding a public raw_body reader to Minfraud::HTTPService::Response that exposes the unparsed response body. The changeset matches this. The CHANGELOG entry, the respon…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Full details: Title check

Explanation

The title names the main change: adding a public raw_body reader to Minfraud::HTTPService::Response that exposes the unparsed response body. The changeset matches this. The CHANGELOG entry, the response.rb reader and initialization, and the spec check for raw_body all support the title.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

A rabbit reads the JSON stream
And keeps the raw text safe and clean
The parsed score sits by its side
Both forms are ready to provide
The changelog notes what’s new today

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 94f83d47-5713-4cad-9d1b-f910052f3251
Commits

Reviewing files that changed from the base of the PR and between c14de27 and ee32033.

Files selected for processing: 3

  • CHANGELOG.md
  • lib/minfraud/http_service/response.rb
  • spec/http_spec.rb

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant