Skip to content

THRIFT-6110: Reject empty successful Ruby HTTP responses#3650

Merged
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-http-empty-response
Jul 21, 2026
Merged

THRIFT-6110: Reject empty successful Ruby HTTP responses#3650
kpumuk merged 1 commit into
apache:masterfrom
kpumuk:rb-http-empty-response

Conversation

@kpumuk

@kpumuk kpumuk commented Jul 20, 2026

Copy link
Copy Markdown
Member

Return a typed transport error when Thrift::HTTPClientTransport receives a successful HTTP response without a Thrift payload.

This handles both 204 responses with no body and 200 responses with an empty body, so callers no longer receive an unrelated NoMethodError while normal responses and existing HTTP-status handling remain unchanged.

  • Did you create an Apache Jira ticket? THRIFT-6110
  • If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
  • Did you squash your changes to a single commit? (not required, but preferred)
  • Did you do your best to avoid breaking changes? If one was needed, did you label the Jira ticket with "Breaking-Change"?
  • If your change does not involve any code, include [skip ci] anywhere in the commit message to free up build resources.

Copilot AI review requested due to automatic review settings July 20, 2026 22:46
@mergeable mergeable Bot added the ruby Pull requests that update Ruby code label Jul 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Ruby Thrift::HTTPClientTransport to raise a Thrift::TransportException when an HTTP request succeeds (2xx) but returns no Thrift payload, avoiding downstream non-transport exceptions for empty responses.

Changes:

  • Add an explicit empty-body check in HTTPClientTransport#flush for successful (2xx) responses.
  • Add RSpec coverage for both 204 with no body and 200 with an empty body.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lib/rb/spec/http_client_spec.rb Adds a spec asserting a typed transport exception is raised for 2xx responses with no payload.
lib/rb/lib/thrift/transport/http_client_transport.rb Adds a guard to reject nil/empty successful HTTP response bodies before attempting to wrap them as an input buffer.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lib/rb/lib/thrift/transport/http_client_transport.rb Outdated
Copilot AI review requested due to automatic review settings July 20, 2026 23:51
@kpumuk
kpumuk force-pushed the rb-http-empty-response branch from 4657c2f to 57a6589 Compare July 20, 2026 23:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kpumuk

kpumuk commented Jul 20, 2026

Copy link
Copy Markdown
Member Author

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This is a little bit sad. Wonder if I reached monthly quota and to get more reviews I will need to wait till the beginning of the next month.

Edit: on the /copilot page found "You've used 95% of your included AI credits. Limit resets on Jul 31." I do not use Copilot outside of Thrift project code reviews, very curious the limits are these low for OSS developers.

Edit2:
CleanShot 2026-07-20 at 19 57 17@2x

@Jens-G

Jens-G commented Jul 21, 2026

Copy link
Copy Markdown
Member

Code review

Found 1 issue:

  1. The new empty-body check in flush raises on every successful oneway call. A oneway RPC never gets write_result invoked server-side (the generated process_XXX returns immediately for oneway functions), so the server legitimately answers with HTTP 200 and a zero-length body — exactly the condition this PR now treats as an error. test/rb/integration/TestClient.rb already skips oneway assertions for the HTTP transport (omit('oneway behavior is server-specific over HTTP')), which is why CI won't catch this.

data = resp.body
if data.nil? || data.empty?
raise TransportException.new(TransportException::UNKNOWN, "#{self.class.name} received an empty response")
end
data = Bytes.force_binary_encoding(data)

// Shortcut out here for oneway functions
if (tfunction->is_oneway()) {
f_service_.indent() << "return" << '\n';
f_service_.indent_down();
f_service_.indent() << "end" << '\n' << '\n';
return;
}

🤖 Generated with Claude Code

- If this code review was useful, please react with 👍. Otherwise, react with 👎.

…l responses

Client: rb

Co-Authored-By: OpenAI Codex (GPT-5.6) <codex@openai.com>
@kpumuk
kpumuk force-pushed the rb-http-empty-response branch from 57a6589 to 15d47d9 Compare July 21, 2026 00:55
Copilot AI review requested due to automatic review settings July 21, 2026 00:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@kpumuk
kpumuk merged commit 41ab486 into apache:master Jul 21, 2026
95 checks passed
@kpumuk
kpumuk deleted the rb-http-empty-response branch July 21, 2026 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ruby Pull requests that update Ruby code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants