User ip_address Overwritten Despite Being Set via Sentry.set_user
Closed this issue · 1 comments
Issue Description
When the @send_default_pii
flag is set to true, the ip_address
set via Sentry.set_user
is being overwritten by the IP address calculated from the Rack environment (calculate_real_ip_from_rack
). This behavior is not intended and leads to incorrect IP address information being sent to Sentry.
After attempting to disable the send_default_pii flag, the ip_address set via Sentry.set_user was correctly reflected in Sentry. This confirms that the issue is related to the send_default_pii flag causing the IP address to be overwritten by calculate_real_ip_from_rack
.
sentry-ruby/sentry-ruby/lib/sentry/event.rb
Lines 103 to 115 in 36866c5
Reproduction Steps
Sentry.set_user(
ip_address: '123.123.123.123'
)
Expected Behavior
The ip_address set via Sentry.set_user using request.remote_ip should be correctly recorded and not overwritten by calculate_real_ip_from_rack
.
Actual Behavior
When @send_default_pii is true, the ip_address set via Sentry.set_user is overwritten by the IP address calculated from calculate_real_ip_from_rack
. This results in Cloudflare’s IP address being recorded in Sentry instead of the actual client’s IP address. This discrepancy may arises because the cloudflare-rails gem modifies the IP addresses to Cloudflare’s proxies without change trusted proxies.
Ruby Version
3.2.2
SDK Version
5.18.1
Integration and Its Version
No response
Sentry Config
Sentry.init do |config|
config.dsn = ''
config.breadcrumbs_logger = %i[active_support_logger http_logger]
config.send_default_pii = true
end
@ryush00 thx for the report, will fix very soon