Skip to content

ActiveRecordSubscriber fails even sooner on queries using unnamed binds #2786

Closed

Description

@midnightmonster

Issue Description

ActiveRecordSubscriber is completely broken for us anyway (#2785 ), but sometimes it breaks even faster.

If your query uses an unnamed bind, like Account.where("email = ?", "foo@example.com"), you'll get these errors instead:

Image

Reproduction Steps

  1. Install sentry-ruby 6.1 on a Rails 8.0.3 app on MRI (with postgres, or probably almost anything)
  2. Configure Sentry.configuration.send_default_pii = true
  3. Attempt to run a query with an unnamed bound parameter, e.g., Account.where("email = ?", "foo@example.com").first

Expected Behavior

Sentry logs the query (though very understandable if it couldn't safely provide the bound value)

Actual Behavior

Sentry logs its own failure to log the query

Ruby Version

3.3.2

SDK Version

sentry-rails 6.1.0 (not sure what this is asking)

Integration and Its Version

Rails 8.0.3

Sentry Config

# config/initializers/sentry.rb
Sentry.init do |config|
  config.dsn = ENV["SENTRY_EU_DSN"]
  config.breadcrumbs_logger = [:active_support_logger, :http_logger]

  if ENV["SENTRY_LOGGING_ENABLED"]
    config.enable_logs = true
    config.enabled_patches = [:logger]
    config.rails.structured_logging.enabled = true
    config.send_default_pii = true

    config.rails.structured_logging.subscribers = {
      action_controller: Sentry::Rails::LogSubscribers::ActionControllerSubscriber,
      active_record: Class.new(Sentry::Rails::LogSubscribers::ActiveRecordSubscriber) do
        def sql(event)
          # SolidQueue database queries are too noisy
          return if event.payload[:name]&.starts_with?("SolidQueue::")
          super
        end
      end
    }
  end

  # TODO: If/when `sentry-rails` adds solid_queue or ActiveJob support for not
  # reporting exceptions from retried jobs (as it does for Sidekiq and DelayedJob),
  # use that and stop excluding `CompletedDocument::MissingFolder`
  config.excluded_exceptions += ["CompletedDocument::MissingFolder"]

  config.traces_sample_rate = 1.0
  config.traces_sampler = lambda do |context|
    true
  end

  config.profiles_sample_rate = 1.0

  config.release = ENV.fetch("HEROKU_RELEASE_VERSION", "")
end

Activity

  1. linear commented on Nov 21, 2025

    @linear
  2. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Nov 21, 2025
  3. solnic commented on Nov 22, 2025

    @solnic
    Collaborator

    Thanks for reporting the issue and I'm sorry it didn't work for you. We run tests only against SQLite and I have to admit it crossed my mind that we need to start running against more db types 😅 I'll take care of this ASAP and we'll push a release Monday/Tuesday.

  4. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Nov 22, 2025
  5. self-assigned this
    on Nov 22, 2025
  6. added a commit that references this issue on Nov 24, 2025
    a11b027
  7. added 2 commits that reference this issue on Nov 24, 2025
    0613dfc
    ce36b19
  8. added a commit that references this issue on Nov 24, 2025
    a5cee1b
  9. solnic commented on Nov 25, 2025

    @solnic
    Collaborator

    @midnightmonster both issues have been fixed in 6.1.2!

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

Metadata

Metadata

Assignees

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions