Skip to content

fix: google sheets metadata maintenance - #4463

Merged
vinayteki95 merged 1 commit into
developfrom
fix.googlesheets
Jul 8, 2025
Merged

vinayteki95 merged 1 commit into
developfrom
fix.googlesheets

Conversation

@vinayteki95

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

The Google Sheets destination's processRouterDest function was producing duplicate outputs when processing failed events, resulting in both an empty success response and an error response for the same input event.

This caused:

  • Duplicate metadata appearing in both success and error responses
  • Empty success responses with no actual data but including failed event metadata
  • Inconsistent output counts where input count ≠ output count
  • Downstream processing issues due to misleading success indicators ( leading to in-out mismatch error on the service side and alerts getting triggered )

Root Cause Analysis Primary Issues Identified:

  • Missing else Statement: Logic bug where both conditional branches executed
  • Incorrect Metadata Handling: Always included ALL input metadata in success response regardless of actual success/failure
  • No Success Response Filtering: Created success responses even when no events succeeded

What is the related Linear task?

Resolves INT-3755

Please explain the objectives of your changes below

In response to this alert caused by googlesheets behaviour

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

Yes, response of googlesheets destination is changed.

Any new dependencies introduced with this change?

No

Any new generic utility introduced or modified. Please explain the changes.

No

Any technical or performance related pointers to consider with the change?

No

@coderabbitai review


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • Is the PR limited to 10 file changes?

  • Is the PR limited to one linear task?

  • Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

@vinayteki95
vinayteki95 requested review from a team and sivashanmukh as code owners July 8, 2025 07:17
@vinayteki95
vinayteki95 requested review from a team, koladilip and maheshkutty July 8, 2025 07:17
@coderabbitai

coderabbitai Bot commented Jul 8, 2025 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of successful event responses to ensure metadata is accurately tracked and returned only for successful events.
    • Success responses are now generated only when there are successful events, preventing empty or incorrect success batches.
  • Other

    • Enhanced reliability of response batching and metadata association for processed events.

Walkthrough

The processRouterDest function in the Google Sheets destination transformer was updated to separately track metadata for successful events, ensuring that metadata aligns precisely with each successful response. The function now only generates batched success responses when there are successful events, and error responses are appended as before.

Changes

File(s) Change Summary
src/v0/destinations/googlesheets/transform.js Refactored processRouterDest to track success metadata separately, batch only if successes exist, and align metadata with responses.

Sequence Diagram(s)

sequenceDiagram
    participant InputEvents
    participant processRouterDest
    participant SuccessResponses
    participant ErrorResponses

    InputEvents->>processRouterDest: Provide input events
    loop For each event
        processRouterDest->>processRouterDest: Process event
        alt Success
            processRouterDest->>SuccessResponses: Add event and metadata
        else Error
            processRouterDest->>ErrorResponses: Add error response
        end
    end
    alt Any successes
        processRouterDest->>SuccessResponses: Batch and attach metadata
    end
    processRouterDest->>InputEvents: Return [SuccessResponses, ErrorResponses]
Loading

Suggested reviewers

  • sivashanmukh
  • krishna2020

Suggestions for improvement:
Consider adding unit tests to verify the new metadata tracking logic and ensure that batched responses are only created when appropriate. Additionally, documenting the structure of the success metadata could aid future maintainability.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9cd5256 and 8de1054.

⛔ Files ignored due to path filters (2)
  • test/integrations/destinations/googlesheets/router/data.ts is excluded by !**/test/**
  • test/integrations/testTypes.ts is excluded by !**/test/**
📒 Files selected for processing (1)
  • src/v0/destinations/googlesheets/transform.js (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.js`: Focus on ESLint errors (max 3) and warnings (max 5).

**/*.js: Focus on ESLint errors (max 3) and warnings (max 5).

⚙️ Source: CodeRabbit Configuration File

List of files the instruction was applied to:

  • src/v0/destinations/googlesheets/transform.js
🧠 Learnings (2)
📓 Common learnings
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4380
File: src/v0/destinations/google_adwords_remarketing_lists/config.js:3-5
Timestamp: 2025-06-04T07:24:58.591Z
Learning: User maheshkutty prefers to handle Google Ads API version upgrades for different destinations in separate pull requests rather than bundling multiple destinations together in a single PR.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.
src/v0/destinations/googlesheets/transform.js (4)
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` is used by both Mixpanel and Google AdWords Offline Conversions destinations in production. The function assumes metadata is always an array in multiple operations (forEach, filter, sort, map) and needs defensive programming to handle non-array metadata cases to prevent runtime errors.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the ArraySpreader/BaseSpreader middleware, error handling for the transform function is already implemented in the caller (BaseSpreader's middleware method), making additional error handling in individual transform functions unnecessary.
Learnt from: maheshkutty
PR: rudderlabs/rudder-transformer#4359
File: src/v0/util/index.js:2272-2272
Timestamp: 2025-05-29T13:29:39.436Z
Learning: The `combineBatchRequestsWithSameJobIds` function in `src/v0/util/index.js` assumes metadata is always an array throughout its implementation, but defensive programming should be added to handle cases where metadata might not be an array type to prevent runtime errors.
Learnt from: ItsSudip
PR: rudderlabs/rudder-transformer#4186
File: src/middlewares/arraySpreader.ts:48-63
Timestamp: 2025-04-08T02:59:55.677Z
Learning: In the BaseSpreader middleware implementation, error handling for transform functions is already handled in the middleware() method with a try-catch block, which wraps errors in a PlatformError. This makes additional error handling inside individual transform functions unnecessary.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: Build Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Build User Transformer Docker Image - PR / Build Transformer Docker Image AMD64
  • GitHub Check: Code Coverage
  • GitHub Check: test_and_publish
  • GitHub Check: UT Tests
  • GitHub Check: Analyze (actions)
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
src/v0/destinations/googlesheets/transform.js (3)

113-113: Good addition: Separate metadata tracking for successful events.

The introduction of successMetadata array properly addresses the core issue of metadata misalignment mentioned in the PR objectives.


121-121: Correct metadata tracking implementation.

The metadata is now properly tracked only for successful events, ensuring that success responses contain accurate metadata that corresponds exactly to the successful events.

Also applies to: 125-125


134-147: Excellent fix: Conditional success response creation prevents empty responses.

This change directly addresses the main issue described in the PR objectives. The function now only creates success responses when there are actual successful events, preventing:

  • Empty success responses containing failed event metadata
  • Duplicate outputs for failed events
  • Inconsistent input/output counts

The implementation correctly batches successful responses and maintains proper spreadsheet configuration while ensuring metadata alignment.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@vinayteki95
vinayteki95 requested review from ItsSudip and utsabc July 8, 2025 07:17
@vinayteki95 vinayteki95 changed the title fix: stream dest test type fix fix: google sheets metadata maintenance Jul 8, 2025
@devops-github-rudderstack

Copy link
Copy Markdown
Contributor

Allure Test reports for this run are available at:

@codecov

codecov Bot commented Jul 8, 2025 •

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.

Project coverage is 91.25%. Comparing base (fe6801a) to head (8de1054).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
src/v0/destinations/googlesheets/transform.js 91.66% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4463      +/-   ##
===========================================
+ Coverage    91.24%   91.25%   +0.01%     
===========================================
  Files          639      639              
  Lines        33658    33664       +6     
  Branches      7938     7946       +8     
===========================================
+ Hits         30710    30720      +10     
+ Misses        2712     2708       -4     
  Partials       236      236              

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

sonarqubecloud Bot commented Jul 8, 2025

Copy link
Copy Markdown

@vinayteki95
vinayteki95 merged commit b23d9a8 into develop Jul 8, 2025
@vinayteki95
vinayteki95 deleted the fix.googlesheets branch July 8, 2025 14:13
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