Skip to content

[BUG]: Rails upgrade to 8.1 causes undefined method 'path_parameters' #5040

@renchap

Description

@renchap

Tracer Version(s)

2.22.0

Ruby Version(s)

ruby 3.4.7 (2025-10-08 revision 7a5688e2a2) +PRISM [arm64-darwin25]

Relevent Library and Version(s)

Rails 8.1.1

Bug Report

When updating our app from Rails 8.0.4 to Rails 8.1.1, all web requests started to fail with the following error:

NoMethodError: undefined method 'path_parameters' for an instance of Rack::Request (NoMethodError)

When disabling the AppSec Rails integration (commenting c.appsec.instrument :rails), the error does not occur.

I am not sure if this comes from an interaction with another library, but the commit introducing this is simply bumping the Rails gems.

Reproduction Code

No response

Configuration Block

Datadog.configure do |c|
  enabled = !Rails.env.local?

  c.env = Rails.env

  c.tracing.enabled = enabled
  c.remote.enabled = enabled

  c.service = 'notos'
  c.tags = { 'app' => 'notos' }
  c.version = Notos::VERSION

  c.tracing.log_injection = !Rails.env.local?
  c.diagnostics.startup_logs.enabled = !Rails.env.local?

  c.tracing.instrument :rack, { request_queuing: true }
  c.tracing.instrument :rails
  c.tracing.instrument :action_cable
  c.tracing.instrument :active_job
  c.tracing.instrument :redis
  c.tracing.instrument :http, { split_by_domain: true }
  c.tracing.instrument :faraday, { split_by_domain: true }
  c.tracing.instrument :httprb, { split_by_domain: true }

  c.appsec.enabled = enabled
  c.appsec.instrument :rails

  # c.diagnostics.debug = true
end

Error Logs

There are no Datadog errors, but a Ruby exception

NoMethodError: undefined method 'path_parameters' for an instance of Rack::Request (NoMethodError)
        req_params  = req.path_parameters
                         ^^^^^^^^^^^^^^^^
    from action_dispatch/journey/router.rb:44:in 'recognize'
    from datadog/appsec/api_security/route_extractor.rb:60:in 'Datadog::AppSec::APISecurity::RouteExtractor.route_pattern'
    from datadog/appsec/api_security/sampler.rb:47:in 'sample?'
    from datadog/appsec/api_security.rb:14:in 'Datadog::AppSec::APISecurity.sample?'
    from datadog/appsec/contrib/rack/request_middleware.rb:109:in 'call'
    from datadog/tracing/contrib/rack/middlewares.rb:70:in 'block in Datadog::Tracing::Contrib::Rack::TraceMiddleware#call'
    from datadog/tracing/contrib/rack/trace_proxy_middleware.rb:17:in 'Datadog::Tracing::Contrib::Rack::TraceProxyMiddleware.call'
    from datadog/tracing/contrib/rack/middlewares.rb:49:in 'call'
    from rails/engine.rb:534:in 'call'
    from puma/configuration.rb:300:in 'call'
    from puma/request.rb:101:in 'block in Puma::Request#handle_request'
    from puma/thread_pool.rb:355:in 'with_force_shutdown'
    from puma/request.rb:100:in 'handle_request'
    from puma/server.rb:503:in 'process_client'
    from puma/server.rb:262:in 'block in Puma::Server#run'
    from puma/thread_pool.rb:182:in 'block in Puma::ThreadPool#spawn_thread'

Operating System

Darwin Kernel Version 25.1.0: Mon Oct 20 19:32:41 PDT 2025; root:xnu-12377.41.6~2/RELEASE_ARM64_T6000 arm64

How does Datadog help you?

No response

Metadata

Metadata

Assignees

Labels

bugInvolves a bugcommunityWas opened by a community member

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions