Skip to content

use status code explicitly in central config#1615

Open
YegorZdanovich wants to merge 1 commit into
elastic:mainfrom
YegorZdanovich:fix-http-status-central_config
Open

use status code explicitly in central config#1615
YegorZdanovich wants to merge 1 commit into
elastic:mainfrom
YegorZdanovich:fix-http-status-central_config

Conversation

@YegorZdanovich

@YegorZdanovich YegorZdanovich commented Apr 10, 2026

Copy link
Copy Markdown

Summary

In http 6.0.0, HTTP::Response::Status was changed from inheriting Delegator to using Comparable + Forwardable. This breaks Range#=== in CentralConfig#fetch_config:

status = HTTP::Response::Status.new(200)
(200..299) === status      # => false (http 6.x)
(200..299) === status.to_i # => true

The case falls through all branches, returns nil, and handle_success(nil) raises NoMethodError: undefined method 'headers' for nil — breaking central config polling silently.

Fix

case resp.status → case resp.status.code in central_config.rb.

Note on v4.8.0

This bug is live in v4.8.0, which has no upper bound on the http dependency (>= 3.0). When Bundler resolves http 6.x, central config breaks silently. A patch release is needed to ship this fix to existing users.

Reproduction

  require "http" # v6.x

  status = HTTP::Response::Status.new(200)

  result = case status
           when 200..299 then :matched
           end

  puts result.inspect  # => nil (expected :matched)

Environment

  • elastic-apm 4.8.0
  • http 6.0.2
  • Ruby 3.3.4

@cla-checker-service

cla-checker-service Bot commented Apr 10, 2026

Copy link
Copy Markdown

💚 CLA has been signed

@YegorZdanovich YegorZdanovich marked this pull request as ready for review April 10, 2026 14:00
@YegorZdanovich YegorZdanovich force-pushed the fix-http-status-central_config branch from 7b18ebc to 3230abd Compare April 10, 2026 14:14
@hegerchr

Copy link
Copy Markdown
Contributor

@YegorZdanovich thanks for creating this contribution. The proposed changes are breaking for http <6.0. May I ask you to update your branch with the latest changes from main and ensure backwards compatibility with previous http versions?

@janko

janko commented Jun 1, 2026

Copy link
Copy Markdown

We got bitten by this as well. Due to elastic APM silently failing to pull remote config, this resulted in excessive traffic towards our Observability cluster, and it took a long time to troubleshoot. We needed to monkey-patch http.rb in order to fix this.

@ericmustin ericmustin mentioned this pull request Jun 2, 2026
@ericmustin

Copy link
Copy Markdown

I rebased this and made a pr #1622

@YegorZdanovich YegorZdanovich force-pushed the fix-http-status-central_config branch from abce0f4 to dac5f9e Compare June 12, 2026 07:43
@YegorZdanovich

Copy link
Copy Markdown
Author

@hegerchr sorry for delay, rebased main.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants