Conversation
The README says to quote `response.request_id` when reporting a problem to Typesafe. It was only ever set on a successful response. On a failure -- the case you would actually report -- the header was in ApiError#headers and nothing pointed at it, so the one identifier support asks for was the one thing the error did not surface. Everything else on a successful response was dropped too. The client scanned the headers for the request id and discarded the rest, so rate-limit counters, which it has no opinion about and no business consuming, were gone by the time anything could read them. ApiError gains #request_id and #endpoint. Response gains #headers and #header(name). The case-insensitive lookup that Client and RetryPolicy had each written for themselves is now Headers.fetch, in one place, still taking the first value of an Array the way Net::HTTP hands back a repeated header. Response.new takes headers: where it took request_id:; #request_id reads the same value out of them. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The README says to quote
response.request_idwhen reporting a problem to Typesafe. It was only ever set on a successful response. On a failure — the case you'd actually report — the header sat inApiError#headersand nothing pointed at it, so the one identifier support asks for was the one thing the error didn't surface.Everything else on a successful response was dropped too. The client scanned the headers for the request id and discarded the rest, so rate-limit counters — which it has no opinion about and no business consuming — were gone by the time anything could read them.
The fix
ApiErrorgains#request_idand#endpoint.Responsegains#headersand#header(name). The case-insensitive lookup thatClientandRetryPolicyhad each written for themselves becomesHeaders.fetch, in one place, still taking the first value of an Array the wayNet::HTTPhands back a repeated header.Response.newtakesheaders:where it tookrequest_id:;#request_idreads the same value out of them.Tests
test/metadata_test.rb, 11 cases.Draft: part of a security and API-coverage audit, opened for reference rather than as a request for immediate review. Independent of the other branches, each off
main. Suite green on Ruby 3.2.11, 3.3.8 and 3.4.8.🤖 Generated with Claude Code