Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions sentry-ruby/3209/Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
source "https://rubygems.org"

gem "logger"
gem "sentry-ruby", "7.2.0"
28 changes: 28 additions & 0 deletions sentry-ruby/3209/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
GEM
remote: https://rubygems.org/
specs:
bigdecimal (4.1.3)
concurrent-ruby (1.3.8)
logger (1.7.0)
sentry-ruby (7.2.0)
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
logger

PLATFORMS
ruby
x86_64-linux

DEPENDENCIES
logger
sentry-ruby (= 7.2.0)

CHECKSUMS
bigdecimal (4.1.3) sha256=61ebe1e5e559bdc3cc6f2c0ee7f427321fc838f59611c294356eb04d6e21cf66
bundler (4.1.0) sha256=d7b7a797b988e544a0677a9c6ed78146f2f63d05ae1af8bc7d9426cf88b46377
concurrent-ruby (1.3.8) sha256=b2f1be836e968ccc78ccfce277ea79c72a88633f22306782c16ff23fb415d1e1
logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203
sentry-ruby (7.2.0) sha256=2da448c2b7028a7691f31ae5c946830b8e694d0aec78ef2b9e5c7e1da9c3e01a

BUNDLED WITH
4.1.0
54 changes: 54 additions & 0 deletions sentry-ruby/3209/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Reproduction for sentry-ruby#3209

**Issue:** https://github.com/getsentry/sentry-ruby/issues/3209

## Description

When an envelope item is still larger than `MAX_SERIALIZED_PAYLOAD_SIZE` after
`Envelope::Item#serialize` removes breadcrumbs and trims stack frames,
`Transport#serialize_envelope` skips it with only a `log_debug` line. No lost
event is recorded, so no client report reaches Sentry, and at the usual `info`
log level nothing is logged at all.

The size reduction does not touch `extra` or `contexts`, so a large custom
payload (here about 1.3 MB of ids in `extra`) is enough to trigger the drop.

The script uses an in-memory transport and a dummy DSN, so nothing is sent.

## Steps to Reproduce

1. Install dependencies:

```bash
bundle install
```

2. Run the reproduction:

```bash
bundle exec ruby repro.rb
```

The script exits 1 while the bug is present and 0 once it is fixed.

## Expected Behavior

- The drop is logged at `warn` level, like the HTTP 413 path.
- A lost event is recorded (`[:send_error, "error"]` in
`transport.discarded_events`), so it shows up in the org's stats via client
reports.

## Actual Behavior

```text
envelopes sent: 0
discarded events: {}
warn+ log lines: 0
BUG: the oversized event was not recorded as a lost event
BUG: the drop was not logged at warn level or above
```

## Environment

- Ruby: 4.0.9
- sentry-ruby: 7.2.0
53 changes: 53 additions & 0 deletions sentry-ruby/3209/repro.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
require "logger"
require "stringio"
require "sentry-ruby"

# Captures envelopes in memory instead of sending them, so nothing leaves the process.
class InMemoryTransport < Sentry::Transport
attr_reader :sent

def initialize(*)
super
@sent = []
end

def send_data(data, options = {})
@sent << data
end
end

log = StringIO.new

Sentry.init do |config|
config.dsn = "https://public@example.com/1"
config.background_worker_threads = 0
config.transport.transport_class = InMemoryTransport
# The usual production log level: debug messages are hidden.
config.sdk_logger = Logger.new(log, level: Logger::INFO)
end

# ~1.3 MB of `extra`. Envelope::Item#serialize only drops breadcrumbs and trims
# stack frames, so this event stays above MAX_SERIALIZED_PAYLOAD_SIZE and the
# transport skips it.
Sentry.capture_message("Found records", extra: { ids: (1..200_000).to_a })

transport = Sentry.get_current_client.transport
discarded = transport.discarded_events
warnings = log.string.lines.grep(/\A[WEF],/)

puts "envelopes sent: #{transport.sent.size}"
puts "discarded events: #{discarded.inspect}"
puts "warn+ log lines: #{warnings.size}"
puts log.string unless log.string.empty?

failures = []
failures << "the oversized event was not recorded as a lost event" unless discarded[[:send_error, "error"]].to_i >= 1
failures << "the drop was not logged at warn level or above" if warnings.empty?

if failures.empty?
puts "OK: the dropped event is visible"
exit 0
else
failures.each { |f| puts "BUG: #{f}" }
exit 1
end
Loading