Skip to content

fix: classify reverse-ETL sources from config for MAR metering - #7159

Merged
am6010 merged 4 commits into
release/1.80.xfrom
fix/pro-5810-stamp-source_category-from-source-config-in-gateway-internal
Jul 8, 2026
Merged

am6010 merged 4 commits into
release/1.80.xfrom
fix/pro-5810-stamp-source_category-from-source-config-in-gateway-internal

Conversation

@am6010

@am6010 am6010 commented Jul 7, 2026 •

Copy link
Copy Markdown
Contributor

What & why

MAR (Monthly Active Records) metering for reverse-ETL / Audiences sources produced no data in clustered/production deployments: activation_records_reports stayed empty and the MAR API returned [].

The reporter gated reverse-ETL classification on the job's source_category param. That param is populated on the gateway web/auth path, but is empty on the clustered /internal/v1/batch ingestion path (rudder-sources → ingestion-svc → Pulsar → srcrouter → gateway). So every reverse-ETL record was silently skipped — no rows, no skip stats.

Change

Classify reverse-ETL (warehouse) sources from the source config (SourceDefinition.Category) instead of the job param:

  • processor snapshots a source_id → category map once per batch (single lock, category strings only) and passes a lookup func(sourceID string) string into the reporter.
  • records_reporter.GenerateReportsFromJobs gates on that lookup (== "warehouse"), still reading the fingerprint from the raw pre-strip job.

Path-independent (works for /internal/v1/batch, /internal/v1/retl, single-node/mini) and fail-closed: an unknown/missing source_id resolves to "" and is skipped; a spoofed source_category param can't force metering.

This supersedes an earlier gateway-side approach (stamping source_category in the internal-batch handler). Classifying at the consumer keeps the change contained to the MAR feature and independent of ingestion topology, and mirrors the sibling tracked-users reporter, which already takes a source-config lookup.

Tests

records_reporter_test.go: warehouse source metered with an empty source_category param; non-warehouse source skipped; a spoofed source_category=warehouse param does not win over config; unknown source skipped fail-closed.

Validation

Verified end-to-end in dev (profiles-qa): reverse-ETL sync → rows in activation_records_reports → flushed to the reporting store → MAR API returns per-connection counts (was []).

Linear: PRO-5810

@am6010
am6010 force-pushed the fix/pro-5810-stamp-source_category-from-source-config-in-gateway-internal branch from 5830a2c to a4b51d9 Compare July 7, 2026 13:05
@codecov

codecov Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.66%. Comparing base (3a56ca8) to head (5874e3e).

Additional details and impacted files
@@                Coverage Diff                 @@
##           release/1.80.x    #7159      +/-   ##
==================================================
- Coverage           79.73%   79.66%   -0.07%     
==================================================
  Files                 595      595              
  Lines               66095    66096       +1     
==================================================
- Hits                52700    52655      -45     
- Misses              10278    10328      +50     
+ Partials             3117     3113       -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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes incorrect source_category stamping for jobs created via the gateway’s /internal/v1/batch handler by deriving it from backend source config (SourceDefinition.Category) instead of stream.MessageProperties.SourceType (which is empty for reverse-ETL/source-record messages on the internal-batch path). This ensures downstream MAR metering logic can correctly classify warehouse records.

Changes:

  • Update internal-batch job parameter stamping to use the resolved source config category (SourceDefinition.Category) for source_category.
  • Add a focused unit test covering warehouse, event-stream, config-precedence, and unknown-source scenarios for source_category.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
gateway/handle.go Stamps source_category from backend source config category instead of msg.Properties.SourceType.
gateway/handle_test.go Adds regression test validating source_category derivation behavior for internal-batch extraction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread gateway/handle.go Resolved
am6010 added 2 commits July 7, 2026 19:23
… the source_category param

MAR metering gated on the job's source_category param, which is empty on the clustered /internal/v1/batch ingestion path, so every reverse-ETL record was silently skipped. Classify reverse-ETL (warehouse) sources from the source's SourceDefinition.Category instead: the processor snapshots a source_id -> category map once per batch and passes a lookup into GenerateReportsFromJobs. Path-independent and fail-closed (unknown source resolves to "" and is skipped).

🔒 Scanned for secrets using gitleaks 8.28.0
Classify from the source config lookup: warehouse source is metered with an empty source_category param, a non-warehouse source is skipped, a spoofed source_category=warehouse param does not win over config, and an unknown source is skipped fail-closed.

🔒 Scanned for secrets using gitleaks 8.28.0
@am6010
am6010 force-pushed the fix/pro-5810-stamp-source_category-from-source-config-in-gateway-internal branch from a4b51d9 to bccb7f3 Compare July 7, 2026 16:23
@am6010 am6010 changed the title fix(gateway): derive source_category from source config on internal-batch path fix(activationrecords): classify reverse-ETL sources from config for MAR metering Jul 7, 2026
@am6010
am6010 marked this pull request as ready for review July 7, 2026 16:29
@am6010 am6010 changed the title fix(activationrecords): classify reverse-ETL sources from config for MAR metering fix: classify reverse-ETL sources from config for MAR metering Jul 7, 2026
@am6010
am6010 requested a review from Copilot July 8, 2026 07:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Comment thread processor/processor.go Resolved
… subscriber

getSourceCategoriesBySourceID rebuilt a source_id -> category map on every batch. Build it once when the backend config changes (alongside sourceIdSourceMap/nonEventStreamSources) and return the shared reference, matching getNonEventStreamSources. Eliminates per-batch allocation on the processor hot path; still batch-consistent (the subscriber replaces the whole map on config change).

🔒 Scanned for secrets using gitleaks 8.28.0
@am6010
am6010 force-pushed the fix/pro-5810-stamp-source_category-from-source-config-in-gateway-internal branch from 8a6bba6 to 50d76c8 Compare July 8, 2026 07:46
@am6010
am6010 requested review from itsmihir and mihir20 July 8, 2026 07:55
Comment thread processor/processor.go Resolved
Drop the func(sourceID string) string wrapper around the source_id ->
category map: GenerateReportsFromJobs now takes the map[string]string
directly and indexes it, matching the sibling tracked-users reporter
(which takes its source filter map directly). The processor fetches the
map once via getSourceCategoriesBySourceID() before the reporter's loop
and passes it directly, so the per-batch closure is gone. A nil/missing
source_id still reads as "" and is skipped fail-closed, so behavior is
unchanged.

🔒 Scanned for secrets using gitleaks 8.28.0
@am6010
am6010 requested a review from itsmihir July 8, 2026 09:26
@am6010
am6010 merged commit 8e026e3 into release/1.80.x Jul 8, 2026
73 checks passed
@am6010
am6010 deleted the fix/pro-5810-stamp-source_category-from-source-config-in-gateway-internal branch July 8, 2026 09:54
am6010 pushed a commit that referenced this pull request Jul 9, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.80.1](v1.80.0...v1.80.1)
(2026-07-08)


### Bug Fixes

* classify reverse-ETL sources from config for MAR metering
([#7159](#7159))
([8e026e3](8e026e3))

---
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 Jul 9, 2026
# Description

Syncing patch release v1.80.1 to main branch

**↓↓ Please review and edit commit overrides before merging ↓↓**

BEGIN_COMMIT_OVERRIDE
fix: classify reverse-ETL sources from config for MAR metering (#7159)
END_COMMIT_OVERRIDE

---------

Co-authored-by: Alexandros Milaios <[email protected]>
Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
This was referenced Jul 20, 2026
mihir20 pushed a commit that referenced this pull request Jul 20, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.81.0-rc.1](v1.80.0...v1.81.0-rc.1)
(2026-07-20)


### Features

* run python transformation tests on ephemeral per-request pyt
deployments
([#7177](#7177))
([1008ae7](1008ae7))
* support partition migration job fanout per jobsdb
([#7141](#7141))
([be42e48](be42e48))


### Bug Fixes

* abort snowpipe events on channel bad request
([#7118](#7118))
([6c08584](6c08584))
* avoid redundant transformer statTags unmarshalling
([#7182](#7182))
([c3c283c](c3c283c))
* classify reverse-ETL sources from config for MAR metering
([#7159](#7159))
([fa7870f](fa7870f))
* detect server-side snowpipe channel failures via per-channel status at
stuck threshold
([#7166](#7166))
([581410c](581410c))
* kafkamanager compilation error
([#7189](#7189))
([1fb7f6e](1fb7f6e))
* **kafka:** support insecure TLS skip verify config
([#7022](#7022))
([d01574f](d01574f))
* preserve order when overflowing snowpipe insert batches
([#7178](#7178))
([9c01fa0](9c01fa0))
* quote postgres warehouse ddl identifiers
([#7127](#7127))
([5aeb481](5aeb481))
* **router:** emit invalid payload metric
([#7168](#7168))
([6e2009a](6e2009a))
* update null to #N/A for salesforce bulk upload
([#7151](#7151))
([1dffd93](1dffd93))
* **warehouse:** use pod identity for rudder-storage flow; keep S3-copy
user fallback for user S3 destinations
([#7167](#7167))
([3f9aa32](3f9aa32))


### Miscellaneous

* add contract tests for test endpoints in pytransformer
([#7147](#7147))
([3b210ec](3b210ec))
* bump compose-test to v0.1.5 to remediate pgx CVE-2026-33815
([#7162](#7162))
([7672f96](7672f96))
* **deps:** bump actions/checkout from 6.0.3 to 7.0.0
([#7132](#7132))
([d453c93](d453c93))
* **deps:** bump actions/setup-go from 6.4.0 to 6.5.0
([#7150](#7150))
([75d9648](75d9648))
* **deps:** bump aws-actions/amazon-ecr-login from 2.1.5 to 2.1.6
([#7109](#7109))
([7b2a859](7b2a859))
* **deps:** bump aws-actions/configure-aws-credentials from 6.2.0 to
6.2.2 ([#7152](#7152))
([c984268](c984268))
* **deps:** bump golangci/golangci-lint-action from 9.2.1 to 9.3.0
([#7170](#7170))
([4565d25](4565d25))
* **deps:** bump the frequent group across 1 directory with 4 updates
([#6891](#6891))
([88a0ddf](88a0ddf))
* support compression in bqstream destinations
([#7142](#7142))
([0694f12](0694f12))

---
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>
mihir20 pushed a commit that referenced this pull request Jul 21, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.81.0](v1.80.0...v1.81.0)
(2026-07-20)


### Features

* run python transformation tests on ephemeral per-request pyt
deployments
([#7177](#7177))
([1008ae7](1008ae7))
* support partition migration job fanout per jobsdb
([#7141](#7141))
([be42e48](be42e48))


### Bug Fixes

* abort snowpipe events on channel bad request
([#7118](#7118))
([6c08584](6c08584))
* avoid redundant transformer statTags unmarshalling
([#7182](#7182))
([c3c283c](c3c283c))
* classify reverse-ETL sources from config for MAR metering
([#7159](#7159))
([fa7870f](fa7870f))
* detect server-side snowpipe channel failures via per-channel status at
stuck threshold
([#7166](#7166))
([581410c](581410c))
* kafkamanager compilation error
([#7189](#7189))
([1fb7f6e](1fb7f6e))
* **kafka:** support insecure TLS skip verify config
([#7022](#7022))
([d01574f](d01574f))
* preserve order when overflowing snowpipe insert batches
([#7178](#7178))
([9c01fa0](9c01fa0))
* quote postgres warehouse ddl identifiers
([#7127](#7127))
([5aeb481](5aeb481))
* **router:** emit invalid payload metric
([#7168](#7168))
([6e2009a](6e2009a))
* update null to #N/A for salesforce bulk upload
([#7151](#7151))
([1dffd93](1dffd93))
* **warehouse:** use pod identity for rudder-storage flow; keep S3-copy
user fallback for user S3 destinations
([#7167](#7167))
([3f9aa32](3f9aa32))


### Miscellaneous

* add contract tests for test endpoints in pytransformer
([#7147](#7147))
([3b210ec](3b210ec))
* bump compose-test to v0.1.5 to remediate pgx CVE-2026-33815
([#7162](#7162))
([7672f96](7672f96))
* **deps:** bump actions/checkout from 6.0.3 to 7.0.0
([#7132](#7132))
([d453c93](d453c93))
* **deps:** bump actions/setup-go from 6.4.0 to 6.5.0
([#7150](#7150))
([75d9648](75d9648))
* **deps:** bump aws-actions/amazon-ecr-login from 2.1.5 to 2.1.6
([#7109](#7109))
([7b2a859](7b2a859))
* **deps:** bump aws-actions/configure-aws-credentials from 6.2.0 to
6.2.2 ([#7152](#7152))
([c984268](c984268))
* **deps:** bump golangci/golangci-lint-action from 9.2.1 to 9.3.0
([#7170](#7170))
([4565d25](4565d25))
* **deps:** bump the frequent group across 1 directory with 4 updates
([#6891](#6891))
([88a0ddf](88a0ddf))
* support compression in bqstream destinations
([#7142](#7142))
([0694f12](0694f12))

---
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