Skip to content

feat(topsort): drop zero-priced purchase lines - #5805

Merged
krishna2020 merged 1 commit into
rudderlabs:contrib/5805from
bernirosas:fix/topsort/drop-zero-price-purchase-lines
Nov 19, 2026
Merged

krishna2020 merged 1 commit into
rudderlabs:contrib/5805from
bernirosas:fix/topsort/drop-zero-price-purchase-lines

Conversation

@bernirosas

@bernirosas bernirosas commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

The Topsort destination now removes purchase items whose unitPrice is 0 before sending a purchase to the Topsort Events API.

Purchase Result
Some items priced 0 Sent without those items
Every item priced 0 Skipped as a filtered event (298), not failed
No zero-priced items Unchanged
  • A price of "0" counts as 0, since the mapping already coerces unitPrice to a number.
  • Items with no price at all are still sent.
  • Impressions and clicks are not affected.

What is the related Linear task?

N/A

Please explain the objectives of your changes below

Zero-priced purchase lines should not be reported to Topsort as purchased items.

A purchase whose items are all priced 0 is left with nothing to send. Topsort rejects a purchase without items (no_purchase_items), so the transform throws FilteredEventsError. The job is reported as filtered (298): it is not retried, not counted as an error, and the other jobs in the batch are still delivered.

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

Purchases no longer carry zero-priced items, and a purchase made up only of zero-priced items is no longer sent. See the objectives above for the reason.

Any new dependencies introduced with this change?

N/A

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

N/A

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

N/A


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.

🤖 Generated with Claude Code

Purchase items whose unit price is 0 are removed before the event is
sent. A purchase left with no items is skipped as a filtered event
(298) instead of failed, since Topsort rejects a purchase without
items.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@bernirosas
bernirosas requested review from a team as code owners November 18, 2026 13:14
Copilot AI balanced review requested due to automatic review settings November 18, 2026 13:14
@coderabbitai

coderabbitai Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ce7e82a4-2170-40c6-8232-e0c6f1d38c77

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Tip

👋 New to CodeRabbit? Try chatting in this PR!

Ask questions about the changes or discuss a review suggestion by mentioning @coderabbitai in a PR comment or a reply to a CodeRabbit review comment.

Try: @coderabbitai explain the changes in this PR and what I should focus on when reviewing.

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

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.

🟢 Approval recommended

No active review issues were identified for the Topsort zero-priced purchase-item filtering change.

No open issues 🎉

What changed in this PR

This PR updates the Topsort destination to exclude zero-priced purchase items while preserving unpriced items and leaving clicks and impressions unchanged.

Changes:

  • Removes purchase items with a mapped unitPrice of zero, including prices supplied as "0".
  • Reports purchases containing only zero-priced items as filtered (298), without failing other events in the batch.
  • Adds unit and component coverage for filtering and batch isolation.
File Description
test/​integrations/​destinations/​topsort/​router/​data.ts Adds component coverage for mixed-price and all-zero purchases.
src/​v0/​destinations/​topsort/​utils.ts Filters zero-priced items and skips purchases left without items.
src/​v0/​destinations/​topsort/​routerTransform.test.ts Tests numeric and string zero prices, unpriced items, and batch isolation.

Review effort: Balanced

@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (5549012) to head (7c2b688).
⚠️ Report is 8 commits behind head on contrib/5805.

Additional details and impacted files
@@              Coverage Diff              @@
##           contrib/5805    #5805   +/-   ##
=============================================
  Coverage         92.49%   92.49%           
=============================================
  Files               742      742           
  Lines             41358    41363    +5     
  Branches           9654     9738   +84     
=============================================
+ Hits              38254    38259    +5     
+ Misses             2921     2843   -78     
- Partials            183      261   +78     

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

@krishna2020
krishna2020 changed the base branch from develop to contrib/5805 November 19, 2026 14:07

@krishna2020 krishna2020 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Reviewed at 7c2b688. Merging into contrib/5805 so the full CI runs before it lands on develop.

@krishna2020
krishna2020 merged commit dd6d6d5 into rudderlabs:contrib/5805 Nov 19, 2026
19 of 21 checks passed
@krishna2020

Copy link
Copy Markdown
Collaborator

Thanks! This is now in contrib/5805 and goes to develop through #5808, where the full CI runs. You can follow it there.

krishna2020 added a commit that referenced this pull request Nov 20, 2026
> **Contributed by @bernirosas in #5805** (fork PR). This PR brings
their commits from
> `contrib/5805` to `develop` so the full CI (Docker build +
ingestion-service test,
> SonarCloud) runs. **Merge with "Create a merge commit" (not squash)**
to keep the
> contributor's commits on `develop`.

## What are the changes introduced in this PR?

The Topsort destination now removes purchase items whose `unitPrice` is
0 before sending a purchase to the Topsort Events API.

| Purchase | Result |
| --- | --- |
| Some items priced 0 | Sent without those items |
| Every item priced 0 | Skipped as a filtered event (298), not failed |
| No zero-priced items | Unchanged |

- A price of `"0"` counts as 0, since the mapping already coerces
`unitPrice` to a number.
- Items with no price at all are still sent.
- Impressions and clicks are not affected.

## What is the related Linear task?

N/A

## Please explain the objectives of your changes below

Zero-priced purchase lines should not be reported to Topsort as
purchased items.

A purchase whose items are all priced 0 is left with nothing to send.
Topsort rejects a purchase without items (`no_purchase_items`), so the
transform throws `FilteredEventsError`. The job is reported as filtered
(298): it is not retried, not counted as an error, and the other jobs in
the batch are still delivered.

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

Purchases no longer carry zero-priced items, and a purchase made up only
of zero-priced items is no longer sent. See the objectives above for the
reason.

### Any new dependencies introduced with this change?

N/A

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

N/A

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

N/A

<hr>

### Developer checklist

- [x] My code follows the style guidelines of this project

- [x] **No breaking changes are being introduced.**

- [x] All related docs linked with the PR?

- [x] All changes manually tested?

- [ ] Any documentation changes needed with this change?

- [x] Is the PR limited to 10 file changes?

- [x] Is the PR limited to one linear task?

- [x] 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.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants