Skip to content

fix: use getStringifiedSampleEvent for consistent sample event handling - #6290

Merged
koladilip merged 3 commits into
release/1.58.xfrom
fix/error-reporting-db-tests
Sep 2, 2025
Merged

koladilip merged 3 commits into
release/1.58.xfrom
fix/error-reporting-db-tests

Conversation

@koladilip

@koladilip koladilip commented Sep 1, 2025 •

Copy link
Copy Markdown
Contributor

Description

This PR fixes failing tests in enterprise/reporting/error_reporting_db_test.go by ensuring consistent sample event serialization in the error reporting system.

Problem

The tests were failing due to inconsistent handling of sample events, particularly when they were nil. The original code used string(sampleEvent) which would convert nil to "", but the tests expected "{}" for nil sample events.

Solution

  • Main Fix: Replace string(sampleEvent) with getStringifiedSampleEvent(sampleEvent) in writeGroupedErrors function
  • Test Improvements: Refactor test code to use helper functions and fix mock expectations
  • Config Subscriber: Fix initialization issues by creating fresh test setup for each subtest

Changes Made

Core Fix (enterprise/reporting/error_reporting.go)

// Before
string(sampleEvent),

// After  
getStringifiedSampleEvent(sampleEvent),

This ensures that:

  • nil sample events are converted to "{}" instead of ""
  • Empty sample events are handled consistently
  • Valid JSON sample events are preserved as-is

Test Improvements (enterprise/reporting/error_reporting_db_test.go)

  • Added helper functions to reduce code duplication
  • Fixed go-sqlmock expectation ordering
  • Fixed configSubscriber initialization for PII filtering tests
  • Added comprehensive test for getStringifiedSampleEvent function

Testing

  • ✅ All tests in enterprise/reporting package pass
  • ✅ Specifically fixed tests:
    • TestErrorDetailsReport (all subtests)
    • TestErrorDetailsReport_RateLimiting
    • TestErrorDetailReporter_GetStringifiedSampleEvent (all subtests)

Impact

  • Low Risk: This is a test fix that improves sample event handling consistency
  • No Breaking Changes: The change maintains backward compatibility
  • Improved Reliability: Better handling of edge cases in sample event serialization

Linear Ticket

Resolves https://linear.app/rudderstack/issue/INT-4023/integrate-error-rate-limiter-into-errordetailreporter

Security

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

- Replace string(sampleEvent) with getStringifiedSampleEvent(sampleEvent) in writeGroupedErrors
- This ensures nil sample events are properly converted to '{}' instead of '<nil>'
- Fixes failing tests in error_reporting_db_test.go by ensuring consistent sample event serialization
- All tests in enterprise/reporting package now pass
@koladilip koladilip changed the title Fix: Use getStringifiedSampleEvent for consistent sample event handling fix: Use getStringifiedSampleEvent for consistent sample event handling Sep 1, 2025
@koladilip koladilip changed the title fix: Use getStringifiedSampleEvent for consistent sample event handling fix: use getStringifiedSampleEvent for consistent sample event handling Sep 1, 2025
- Remove unused eventType parameter from createTestMetrics function
- Fix embedded field selectors by removing ConnectionDetails prefix
- Mark unused expectedSampleEvent parameter with underscore
- All tests continue to pass after linting fixes
- Remove eventName parameter from createTestMetrics function signature
- Hardcode EventName to 'User Identified' as it's always the same value
- Update all function calls to match the new signature
- All tests continue to pass after the change
@koladilip
koladilip merged commit 526975c into release/1.58.x Sep 2, 2025
@koladilip
koladilip deleted the fix/error-reporting-db-tests branch September 2, 2025 05:17
This was referenced Sep 2, 2025
itsmihir pushed a commit that referenced this pull request Sep 2, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.58.0-rc.2](v1.57.0...v1.58.0-rc.2)
(2025-09-02)


### Features

* implement error normalizer with similarity detection for reporting
([#6248](#6248))
([b4653d3](b4653d3))
* **router:** delivery throttler
([#6225](#6225))
([f55c7a8](f55c7a8))


### Bug Fixes

* cron tracker query causing master restarts
([#6252](#6252))
([51437b9](51437b9))
* snowpipe events getting duplicated if status API fails
([#6211](#6211))
([#6244](#6244))
([8d6838d](8d6838d))
* transformation metrics count amplification
([#6258](#6258))
([fded7b3](fded7b3))
* update table schema local repository
([#6255](#6255))
([2ec9a9f](2ec9a9f))
* update table schema local repository
([#6255](#6255))
([4446e5b](4446e5b))
* use getStringifiedSampleEvent for consistent sample event handling
([#6290](#6290))
([526975c](526975c))
* use source-id for getting cached schemas
([#6268](#6268))
([2ec9a9f](2ec9a9f))
* use source-id for getting cached schemas
([#6268](#6268))
([90e4191](90e4191))
* warehouse migrations from master only
([#6282](#6282))
([2309507](2309507))


### Miscellaneous

* add alert for stuck snowpipe pipeline
([#6271](#6271))
([2ec9a9f](2ec9a9f))
* add context information on ut http error logs
([#6278](#6278))
([424f22c](424f22c))
* bump amannn/action-semantic-pull-request from 5 to 6
([#6237](#6237))
([41c1548](41c1548))
* bump the go-deps group with 15 updates
([#6247](#6247))
([8d6838d](8d6838d))
* bump the go-deps group with 3 updates
([#6254](#6254))
([02a0263](02a0263))
* cleanup for schema snapshoting
([#6257](#6257))
([4f3a68f](4f3a68f))
* remove flaky GooglePubSub retry configuration tests
([#6260](#6260))
([6c48784](6c48784))
* remove null handling of upload id in load files
([#6241](#6241))
([8d6838d](8d6838d))
* remove unused network code
([#6266](#6266))
([f7cbc94](f7cbc94))
* **router:** rename endpointLabel to endpointPath
([#6279](#6279))
([c933525](c933525))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
itsmihir pushed a commit that referenced this pull request Sep 2, 2025
🤖 I have created a release *beep* *boop*
---


##
[1.58.0](v1.57.0...v1.58.0)
(2025-09-02)


### Features

* implement error normalizer with similarity detection for reporting
([#6248](#6248))
([b4653d3](b4653d3))
* **router:** delivery throttler
([#6225](#6225))
([f55c7a8](f55c7a8))


### Bug Fixes

* cron tracker query causing master restarts
([#6252](#6252))
([51437b9](51437b9))
* snowpipe events getting duplicated if status API fails
([#6211](#6211))
([#6244](#6244))
([8d6838d](8d6838d))
* transformation metrics count amplification
([#6258](#6258))
([fded7b3](fded7b3))
* update table schema local repository
([#6255](#6255))
([2ec9a9f](2ec9a9f))
* update table schema local repository
([#6255](#6255))
([4446e5b](4446e5b))
* use getStringifiedSampleEvent for consistent sample event handling
([#6290](#6290))
([526975c](526975c))
* use source-id for getting cached schemas
([#6268](#6268))
([2ec9a9f](2ec9a9f))
* use source-id for getting cached schemas
([#6268](#6268))
([90e4191](90e4191))
* warehouse migrations from master only
([#6282](#6282))
([2309507](2309507))


### Miscellaneous

* add alert for stuck snowpipe pipeline
([#6271](#6271))
([2ec9a9f](2ec9a9f))
* add context information on ut http error logs
([#6278](#6278))
([424f22c](424f22c))
* bump amannn/action-semantic-pull-request from 5 to 6
([#6237](#6237))
([41c1548](41c1548))
* bump the go-deps group with 15 updates
([#6247](#6247))
([8d6838d](8d6838d))
* bump the go-deps group with 3 updates
([#6254](#6254))
([02a0263](02a0263))
* cleanup for schema snapshoting
([#6257](#6257))
([4f3a68f](4f3a68f))
* remove flaky GooglePubSub retry configuration tests
([#6260](#6260))
([6c48784](6c48784))
* remove null handling of upload id in load files
([#6241](#6241))
([8d6838d](8d6838d))
* remove unused network code
([#6266](#6266))
([f7cbc94](f7cbc94))
* **router:** rename endpointLabel to endpointPath
([#6279](#6279))
([c933525](c933525))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

3 participants