Skip to content

chore: handle oversized reporting payloads - #7293

Merged
itsmihir merged 16 commits into
masterfrom
harness/PIPE-3305-fix-core-handle-oversized-repor-76330dea
Aug 24, 2026
Merged

itsmihir merged 16 commits into
masterfrom
harness/PIPE-3305-fix-core-handle-oversized-repor-76330dea

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Description

The reporting service rejects oversized payloads with HTTP 413. Previously the client retried a 413 like any other non-2xx until the backoff budget was exhausted, the reporting window was not deleted, and the same payload was replayed on the next loop — so one oversized payload wedged the reporter.

This PR makes 413 recoverable, behind a per-reporter feature flag, and adds a write-time size guard for sample events.

Behaviour

client.Send now unconditionally fails fast on a 413: it returns the sentinel client.ErrPayloadTooLarge immediately instead of retrying via backoff. client.SendWithoutFailFast keeps the old behaviour — a 413 is retried like any other non-2xx response.

Each of the three callers gates its own split-and-retry behaviour behind its own reloadable flag (requestEntityTooLargeHandling, config keys below). When the flag is off, the caller calls SendWithoutFailFast directly and the send path is byte-identical to master. When on:

  1. DefaultReporter.sendMetric (enterprise/reporting/reporting.go): calls Send; on ErrPayloadTooLarge, splits the metric into one request per StatusDetail.
  2. ErrorDetailReporter.sendEDMetric (enterprise/reporting/error_reporting.go): same split, one request per EDErrorDetails.
  3. Flusher.sendBatch (enterprise/reporting/flusher/flusher.go, tracked users / activation records): one request per batch item. Flusher items are opaque JSON and cannot be shrunk, so each split item is sent with SendWithoutFailFast directly — there is no strip fallback for this path.
  4. Strip fallback (metrics and error details only, via sendStrippedStatusDetail / sendStrippedErrorDetail): an individual item that still 413s is resent with SampleEvent replaced by {"sample_event_not_available":"entity too large"} via SendWithoutFailFast. SampleResponse is kept. A single-item payload goes straight to this fallback since there is nothing to split.

Write-time size guard (not flag-gated)

A per-reporter maxSampleEventSizeBytes (reloadable): in getSampleWithEventSamplingCore, a sample event larger than this is dropped (isOversized=true, sample event/response cleared) before the event sampler is consulted and before the row is written, regardless of whether event sampling is enabled or the flag above is set.

Config

Key Default Reloadable
Reporting.requestEntityTooLargeHandling false yes
Reporting.errorReporting.requestEntityTooLargeHandling (falls back to the key above) false yes
Reporting.flusher.requestEntityTooLargeHandling (falls back to the key above) false yes
Reporting.maxSampleEventSizeBytes 83886080 (80 MB) yes
Reporting.errorReporting.maxSampleEventSizeBytes (falls back to the key above) 52428800 (50 MB) yes
Reporting.httpClient.backoff.maxRetries (pre-existing, now load-bearing) unset → backoff default 15 min elapsed no

Note: the error-detail reporter's write-time guard defaults to 50 MB, lower than the metrics reporter's 80 MB — intentional, not a leftover.

Metrics

One merged counter per reporter tracks every place a sample event is skipped, distinguished by a stage tag:

Metric Type Tags Meaning
reporting_oversized_sample_event_skipped count stage (sampler|client), sourceId, destinationId DefaultReporter: sampler = dropped by the write-time guard; client = replaced by the placeholder in the strip fallback after a 413
error_detail_reporting_oversized_sample_event_skipped count same as above ErrorDetailReporter equivalent
reporting_client_http_request_payload_bytes histogram client tags (module/instanceId/endpoint/path) uncompressed payload size per send (once per logical send, not per retry); buckets 10KB–100MB in runner/buckets.go

workspaceId is deliberately excluded from the skipped-counter tags to keep cardinality bounded to sourceId/destinationId. There is no separate "split" counter — a 413-triggered split is visible via the generic reporting_client_http_request{status="413",...} stat already emitted by the client.

Performance

client.Client now pre-creates its five fixed-tag stats (StatRequestPayloadBytes, StatRequestLatency, StatRequestTotalBytes, StatRequestCompressedBytes, StatTotalDurationsSeconds) once in New() instead of calling NewTaggedStat on every send() call — their tags (module/instanceId/endpoint/path) never change for a given client instance. StatHttpRequest still creates its stat per-request since it carries a response-status tag that does vary.

Known limitations / follow-ups

  • SampleResponse is not stripped in the fallback. A payload whose bulk is in SampleResponse will still 413 after stripping and will be retried with the normal backoff budget; the window is not deleted and is replayed next loop (same as master today for any persistent 413).
  • No terminal give-up: there is no "drop and move on" for an item that can never be shrunk (flusher items in particular).
  • A split turns one request into N. If request k fails, items 1..k-1 are already delivered and the whole window is replayed on the next loop, so a partial failure can double-count those items (covered explicitly by "partial failure returns error after delivering earlier metrics" in the tests, as a known, accepted trade-off against the old wedge-forever behaviour). For /metrics the service already receives multiple documents with identical ReportMetadata today (groups larger than maxReportsCountInARequest), so merge semantics are established; for /recordErrors this PR is the first to send N documents sharing a group key — please confirm the service merges errors[] rather than upserting.
  • EDMetric.Errors is not capped by maxReportsCountInARequest, so the error-detail split can fan out to many sequential requests inside one goroutine.
  • The 413 response body is not included in ErrPayloadTooLarge, so the server's stated limit is not logged on the handled path.

Linear Ticket

https://linear.app/rudderstack/issue/PIPE-3305

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@rudder-devbox

rudder-devbox Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

👋 I'm rudder-devbox. I opened this PR from a Linear ticket.

Mention @devbox or @rudder-devbox and I'll act on it — on a top-level PR comment,
in a review summary, or on an inline comment on the diff. Without a mention I won't see it.

@codecov

codecov Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.48120% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.68%. Comparing base (239d9a4) to head (9a99389).

Files with missing lines Patch % Lines
enterprise/reporting/error_reporting.go 84.37% 3 Missing and 2 partials ⚠️
enterprise/reporting/reporting.go 91.89% 2 Missing and 1 partial ⚠️
enterprise/reporting/flusher/flusher.go 92.59% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7293      +/-   ##
==========================================
- Coverage   79.71%   79.68%   -0.04%     
==========================================
  Files         601      601              
  Lines       67219    67308      +89     
==========================================
+ Hits        53586    53636      +50     
- Misses      10472    10515      +43     
+ Partials     3161     3157       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

itsmihir and others added 2 commits August 20, 2026 13:30
…elpers

- splitOnTooLarge -> failFastOnTooLarge: the client only stops retrying
  on 413, it does not split anything itself
- SendWithoutPayloadTooLargeSplit -> SendWithRetryOnTooLarge
- Reporting.splitOnPayloadTooLarge.enabled -> Reporting.payloadTooLargeHandling.enabled
- move split helpers from payload_too_large.go into reporting.go /
  error_reporting.go / utils.go and split the tests to match
- flusher/payload_too_large_test.go -> flusher/flusher_test.go

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
@rudder-devbox

rudder-devbox Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the CI failure and pushed the commit.

Root cause from the failed Correct generated files log: after make fmt, gci reported Writing formatted File: enterprise/reporting/utils_test.go, and the subsequent git diff --exit-code showed the only diff was a missing blank line between github.com/rudderlabs/rudder-go-kit/... imports and github.com/rudderlabs/rudder-server/... imports.

I applied that formatter-required import grouping in enterprise/reporting/utils_test.go, verified the focused gci command and git diff --check pass, then pushed the fix.

Commit: 24b9daf

@rudder-devbox

rudder-devbox Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

…rden split tests

- when a 413'd metric/batch has a single item, go straight to the stripped
  fallback (metrics) or SendWithRetryOnTooLarge (flusher) instead of
  resending the identical payload first
- extract sendStrippedStatusDetail / sendStrippedErrorDetail helpers; drop
  the unreachable nil-statusDetail branch from metricWithSingleStatusDetail
- replace sampleEventNotAvailableForPayloadTooLarge() with a package var
- tests: partial-failure, non-mutation, single-item short-circuit and
  ED non-413 cases; add sampling-disabled size-guard tests (currently
  failing: guard sits below the sampling-disabled early return in
  getSampleWithEventSamplingCore)

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
…pling

The maxSampleEventSizeBytes check sat below the event-sampling early
return, so with sampling disabled (the default) oversized sample events
were never dropped. Hoist it to the top of getSampleWithEventSamplingCore
so oversized samples are dropped before the sampler is consulted.

Tests: cover both disjuncts of the sampling-disabled early return, assert
sampleResponse is cleared, pin that oversized samples never hit the
sampler, and add an at-limit boundary case.

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
@rudder-devbox

rudder-devbox Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

I could not make a code fix for this CI failure because the logs show an infrastructure/rate-limit failure outside this PR's reporting changes.

Root cause from the failed Package Unit (services) log: services/streammanager/kafka TestNewProducer/ok_ssh failed at kafkamanager_test.go:229 while setting up Docker-backed SSH/Kafka resources with API error (500): toomanyrequests: retry-after: 15.199µs, allowed: 44000/minute. The later nil pointer panic came from cleanup in github.com/rudderlabs/rudder-go-kit/testhelper/docker/resource/sshserver.Setup.func2, after that setup failure. The All log only reports package-unit → failure, so it is downstream of the same job failure.

I left the repository unchanged; there is no source-level failure here to patch from the workspace.

- reporting_payload_too_large_split / error_detail_reporting_payload_too_large_split /
  reporting_flusher_payload_too_large_split: batch rejected with 413 and split
- reporting_sample_event_replaced_too_large / error_detail_reporting_sample_event_replaced_too_large:
  sample event replaced by placeholder in the stripped fallback
- reporting_sample_event_dropped_oversized / error_detail_reporting_sample_event_dropped_oversized:
  sample event dropped by maxSampleEventSizeBytes before reaching the sampler
- reporting_client_http_request_payload_bytes: histogram of uncompressed payload
  size per send, with byte buckets registered in runner/buckets.go

Split helpers become reporter methods so they can reach the client and stats;
tests assert the new counters via memstats.

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
…lit tests

The payload-size histogram called getTags() before the reporting URL was
validated; getTags dereferenced the result of url.Parse without checking
the error, so a malformed REPORTING_URL panicked instead of returning an
error. Check the parse error and record the histogram after URL validation.

Tests: cover the rejected-item strip (not item 0), non-413 batch errors
returned without splitting, flusher in-loop 413 fallback and per-item
abort, client fail-fast scoped to 413 only, and the malformed-URL path.
Test reporters now set log/stats fields so future method changes don't
nil-deref; test tags use a fresh map per call.

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
Flusher batch items are opaque and cannot be shrunk, so a fail-fast Send
followed by SendWithRetryOnTooLarge on the same bytes was one wasted
request per item. Send each item with SendWithRetryOnTooLarge directly;
this also makes the single-item short-circuit redundant.

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
@rudder-devbox

rudder-devbox Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the lint failure on the PR branch.

Root cause from the failed lint log: golangci-lint v2.9.0 reported enterprise/reporting/flusher/flusher_test.go:231:77: requirePayloadTooLargeSplits - want always receives 1 (unparam). At the failed SHA, the helper accepted a want float64 argument, but every caller passed 1.

The branch now removes that always-constant parameter by replacing the helper with requireSinglePayloadTooLargeSplit, which asserts the single expected split count directly. I verified the affected package with golangci-lint run -v ./enterprise/reporting/flusher, which passed with 0 issues.

Commit: 6e06136

…yload

Unify naming around "large payload" / "large sample event" instead of
"payload too large" across reporters, flusher, client and tests.

- sendMetricWithPayloadTooLargeSplit -> sendMetricWithLargePayloadHandler
  (and ED/flusher equivalents)
- SendWithRetryOnTooLarge -> SendWithoutFailFast
- Stat consts gain Counter suffix: *LargePayloadSplitCounter,
  *LargeSampleEventReplacedCounter, *OversizedSampleEventDroppedCounter
- Metric names: *_payload_too_large_split -> *_large_payload_split,
  *_sample_event_replaced_too_large -> *_large_sample_event_replaced,
  *_sample_event_dropped_oversized -> *_oversized_sample_event_dropped
- Config key: Reporting.payloadTooLargeHandling.enabled ->
  Reporting.largePayloadHandling.enabled
- Test helpers: *PayloadTooLarge* -> *LargePayload*

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
…EventDroppedCounter

Co-Authored-By: Claude Fable 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
@itsmihir itsmihir changed the title fix(core): handle oversized reporting payloads chore: handle oversized reporting payloads Aug 20, 2026
@itsmihir
itsmihir marked this pull request as ready for review August 20, 2026 15:36
@itsmihir
itsmihir requested review from atzoum and ktgowtham August 20, 2026 15:36
Comment thread enterprise/reporting/utils.go Resolved
Comment thread enterprise/reporting/client/client.go Resolved
Comment thread enterprise/reporting/flusher/flusher.go Resolved
Comment thread enterprise/reporting/flusher/flusher.go Resolved
Comment thread enterprise/reporting/error_reporting.go Resolved
Comment thread enterprise/reporting/reporting.go Resolved
Comment thread enterprise/reporting/utils.go Resolved
Comment thread enterprise/reporting/reporting.go Resolved
itsmihir and others added 2 commits August 24, 2026 12:35
…mple-event metric

- sendMetricWithLargePayloadHandler/sendEDMetricWithLargePayloadHandler/
  sendBatchWithLargePayloadHandler -> sendMetric/sendEDMetric/sendBatch
- Merge the write-time-guard and 413-placeholder-replace counters into one
  metric per reporter (reporting_oversized_sample_event_skipped /
  error_detail_reporting_oversized_sample_event_skipped), distinguished by a
  "stage" tag (sampler | client) plus sourceId/destinationId
- Drop the generic reporter-level tags (workspaceId, instanceId, clientName)
  that were leaking into the client-stage stat via a tag-merge helper; that
  helper (withStage) is removed now that it has no callers
- Remove the now-unused tags parameter threaded through
  sendMetric/sendStrippedStatusDetail and sendEDMetric/sendStrippedErrorDetail

Co-Authored-By: Claude Sonnet 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
@rudder-devbox

rudder-devbox Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the CI failures and pushed the commit.

Root cause from the logs:

  • Correct generated files failed after make fmt; git diff --exit-code showed gofumpt rewrote two enterprise/reporting/utils.go function signatures to combine adjacent int64 parameters.
  • lint failed with enterprise/reporting/utils_test.go:167:64 and :182:64: unnecessary conversion (unconvert) on config.SingleValueLoader(int64(maxSampleEventSizeBytesForTest)).

I applied the formatter-required signatures and removed the redundant test conversions. Validation passed for:

  • go run mvdan.cc/[email protected] -l -w -extra enterprise/reporting/utils.go enterprise/reporting/utils_test.go
  • go run github.com/daixiang0/[email protected] write ... enterprise/reporting/utils.go enterprise/reporting/utils_test.go
  • golangci-lint run -v ./enterprise/reporting with 0 issues
  • go test -count 1 ./enterprise/reporting -run 'TestGetSampleWithEventSampling|TestGetSampleWithEventSamplingForEDReportsDB|Test.*PayloadTooLarge'

Commit: 8454e74

@rudder-devbox

rudder-devbox Bot commented Aug 24, 2026

Copy link
Copy Markdown
Contributor Author

Knowledge distillation completed

itsmihir and others added 2 commits August 24, 2026 12:52
send() called NewTaggedStat on every request for the five stats whose
tags never change per client (module/instanceId/endpoint/path). Create
them once in New() and reuse the Measurement instead. StatHttpRequest
keeps its per-request NewTaggedStat since it also carries a
response-status tag.

Co-Authored-By: Claude Sonnet 5 <[email protected]>

🔒 Scanned for secrets using gitleaks 8.28.0
@itsmihir
itsmihir requested a review from atzoum August 24, 2026 07:28

@atzoum atzoum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@itsmihir the pr description has now drifted, please align to match recent changes

@itsmihir
itsmihir merged commit 7a83281 into master Aug 24, 2026
74 of 75 checks passed
@itsmihir
itsmihir deleted the harness/PIPE-3305-fix-core-handle-oversized-repor-76330dea branch August 24, 2026 11:29
This was referenced Aug 24, 2026
itsmihir pushed a commit that referenced this pull request Aug 24, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.84.0-rc.1](v1.83.0...v1.84.0-rc.1)
(2026-08-24)


### Features

* add AGENTS.md for agent management and reference
([#7290](#7290))
([2d28b32](2d28b32))
* **processor:** report duplicate events as dedup/filtered metrics
([#7280](#7280))
([f2655fb](f2655fb))
* **warehouse:** add clickhouse driver interface
([#7296](#7296))
([239d9a4](239d9a4))


### Bug Fixes

* **processor:** proc destination hydration omitted destination's
original id
([#7297](#7297))
([f389df4](f389df4))
* **warehouse:** close load file descriptor in identity uploadFile
([#7186](#7186))
([bfd8bc9](bfd8bc9))


### Miscellaneous

* handle oversized reporting payloads
([#7293](#7293))
([7a83281](7a83281))
* pyt security hardening
([#7272](#7272))
([e13b731](e13b731))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
itsmihir pushed a commit that referenced this pull request Aug 25, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.84.0](v1.83.0...v1.84.0)
(2026-08-24)


### Features

* add AGENTS.md for agent management and reference
([#7290](#7290))
([2d28b32](2d28b32))
* **processor:** report duplicate events as dedup/filtered metrics
([#7280](#7280))
([f2655fb](f2655fb))
* **warehouse:** add clickhouse driver interface
([#7296](#7296))
([239d9a4](239d9a4))


### Bug Fixes

* **processor:** proc destination hydration omitted destination's
original id
([#7297](#7297))
([f389df4](f389df4))
* **warehouse:** close load file descriptor in identity uploadFile
([#7186](#7186))
([bfd8bc9](bfd8bc9))


### Miscellaneous

* handle oversized reporting payloads
([#7293](#7293))
([7a83281](7a83281))
* pyt security hardening
([#7272](#7272))
([e13b731](e13b731))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants