Fix code review issues, CVE-2026-33210 pin, and Ruby 4.0 test suite#1
Merged
Conversation
vendor_registry.rb — load-order bug initialize_registry ran at require time and called Apidepth.logger before it was defined (Apidepth class << self block hadn't been evaluated yet). Replaced the replace(BUNDLED_BASELINE) call with a direct assignment so the bundled baseline loads silently without touching the logger. spec/spec_helper.rb — expired double safety net Tests that set a mock @http on the singleton Collector instance leaked the double into the next example's after(:each) teardown, causing "expired test double" failures. Nil out @http on the singleton before reset! so teardown never calls finish on an expired double. spec/sdk_spec.rb — Ruby 4.0 compatibility fixes - Add api_key before hook to Collector describe block: the new send_batch nil/empty guard skips the send when no key is set, so tests that expect network calls must configure one. - cold_start: false test no longer stubs started?. Net::HTTP.start establishes the real connection before yielding to our instrumented request, so started? is naturally true — the stub was both unnecessary and caused a Ruby 4.0 SSL consistency IOError. - Change be_positive to be >= 0 for duration_ms checks: WebMock returns immediately with no delay, so elapsed rounds to 0ms on fast hardware. - Replace be_in([true, false]) with include matcher: be_in requires ActiveSupport which is not loaded in the test suite. - Update SSRF flush! test expectation: flush! now correctly increments consecutive_failures on failure (matching safe_flush behavior), so the old eq(0) assertion was wrong. - Add outcome: :success to event() helper: outcome is a REQUIRED field on Event; the helper was producing hashes that bypass Event.build. - Fix env fallback test: Rails is not loaded in specs; the fallback is "unknown", not Rails.env. - Add tests for empty api_key guard and corrected env fallback. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents all changes from this session: load-order bug fix, empty api_key guard, flush! on_flush_error parity, HTTP connection leak fix, CVE-2026-33210 json pin, core.rb removal, and thread-name guard cleanup. Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
NoMethodErroron Ruby 4.0 at require timeapi_keyguard insend_batchto avoid sending brokenAuthorization: Bearerheadersflush!(at-exit path) in line withsafe_flush: now callson_flush_errorand incrementsconsecutive_failureson failureRegistryLoader.fetch_remotejsonfloor to>= 2.19.2to exclude CVE-2026-33210 (CVSS 9.1)lib/apidepth/core.rbtombstone filebe_inwithout ActiveSupport, SSL consistency error fromstarted?stub, WebMock 0ms duration)What changed and why
lib/apidepth/vendor_registry.rbinitialize_registrycalledreplace(BUNDLED_BASELINE)at require time, which logs viaApidepth.logger. Butloggeris defined inapidepth.rb'sclass << selfblock, which hasn't been evaluated yet whenvendor_registry.rbis first required. Fixed by inlining the state assignment ininitialize_registrywithout the log call.lib/apidepth/collector.rbsend_batch: returns early whenapi_keyis nil or empty — avoids a wasted round-trip that was guaranteed to 401 and burn a failure incrementflush!: rescue block now callson_flush_errorand incrementsconsecutive_failures, matchingsafe_flushbehavior. The at-exit path is the one users are most likely to notice failures inrespond_to?(:name=)guards —Thread#name=has been available since Ruby 2.3; gem requires 2.7+collector_urlmemoization intentlib/apidepth/registry_loader.rbfetch_remotecreates a newNet::HTTPper call and was never callingfinish. Addedhttp&.finish rescue nilin theensureblock. Also removed deadrespond_to?(:name=)guard.apidepth.gemspecjsonfloor to>= 2.19.2— CVE-2026-33210 (CVSS 9.1 Critical) affects json 2.14–2.15.2.0, 2.16–2.17.1.1, and 2.18–2.19.1. Patched in 2.19.2spec/spec_helper.rbAdded a safety nil-out of
@httpon the singleton Collector instance beforereset!runs inafter(:each). Tests that set a mockNet::HTTPdouble on the singleton were leaving it alive past example teardown, causing "expired test double" failures in subsequent tests.spec/sdk_spec.rbbefore { Apidepth.configuration.api_key = "sk_test" }to the Collector describe block — required now thatsend_batchskips when api_key is nilcold_start: falsetest: removedallow_any_instance_ofstub.Net::HTTP.startestablishes a real connection before yielding to our instrumentedrequest, sostarted?is naturally true. The stub was unnecessary and caused a Ruby 4.0 SSL consistencyIOErrorbe_positive→be >= 0forduration_mschecks: WebMock returns with no delay; elapsed rounds to 0ms on fast hardwarebe_in([true, false])withincludematcher:be_inrequires ActiveSupport which is not loaded in the test suiteflush!test:consecutive_failuresshould be 1 after a failed flush now thatflush!tracks failures correctlyevent()helper to includeoutcome: :success(required field)"unknown"(Rails is not loaded in specs)Test plan
bundle exec rspecpasses — 118 examples, 0 failures on Ruby 4.0.3🤖 Generated with Claude Code