Skip to content

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

Merged
krishna2020 merged 2 commits into
developfrom
contrib/5805
Nov 20, 2026
Merged

krishna2020 merged 2 commits into
developfrom
contrib/5805

Conversation

@krishna2020

Copy link
Copy Markdown
Collaborator

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


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

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

Co-authored-by: Claude Opus 5.5 <[email protected]>
@krishna2020
krishna2020 requested review from a team as code owners November 19, 2026 14:08
@coderabbitai

coderabbitai Bot commented Nov 19, 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: 47422b9b-131b-46fd-b143-13109c4770ec

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

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

@codecov

codecov Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.49%. Comparing base (b7adc40) to head (19fea5a).
⚠️ Report is 1 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5808   +/-   ##
========================================
  Coverage    92.49%   92.49%           
========================================
  Files          742      742           
  Lines        41358    41362    +4     
  Branches      9738     9653   -85     
========================================
+ Hits         38254    38258    +4     
- Misses        2843     2921   +78     
+ Partials       261      183   -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.

Comment thread src/v0/destinations/topsort/utils.ts Resolved
Pick the purchased products first (properties.products, or the message
itself for a single-product event), then map and filter them once.
Behaviour is unchanged. Addresses review feedback on #5808.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sonarqubecloud

Copy link
Copy Markdown

@krishna2020
krishna2020 merged commit 7d332ab into develop Nov 20, 2026
38 checks passed
@krishna2020
krishna2020 deleted the contrib/5805 branch November 20, 2026 13:44
ItsSudip pushed a commit that referenced this pull request Nov 23, 2026
…5818)

## What are the changes introduced in this PR?

The Topsort destination no longer sends events or purchase lines that
the Topsort Events API always rejects with a 400.

| Event | Topsort's 400 | Now |
| --- | --- | --- |
| Impression or click with neither `properties.resolvedBidId` nor
`properties.entity` | `Entity ... failed on the 'required_without' tag`
| Fails with a 400 (`InstrumentationError`), not sent |
| Purchase line with no price, or a non-numeric one | `UnitPrice ...
failed on the 'required' tag` | The line is dropped, like a zero-priced
one; the rest of the purchase is sent |
| Purchase with no priced line left | `UnitPrice ...` /
`no_purchase_items` | Fails with a 400 (`InstrumentationError`), not
sent. All lines priced 0 is still skipped as filtered (298), as before |

- Sponsored events (with `resolvedBidId`) and organic events (with
`entity`) are unchanged.
- The check covers every event a message fans out to over `products`,
since both fields come from the message.
- Zero-priced lines are still dropped as before (#5808).

## What is the related Linear task?

N/A

## Please explain the objectives of your changes below

Both rejections were observed on live Events API traffic, for clicks and
purchase lines. No impression without `entity` showed up in that
traffic, so the impression case follows the API reference (impressions
and clicks share the same `resolvedBidId`/`entity` requirement) rather
than an observed 400. Because the Events API rejects a whole request for
one bad event, each of these events currently:

1. rejects the batch it is in, and
2. triggers the 400 handler's `dontBatch` retry, so every job in that
batch is re-sent on its own before the bad one is finally aborted.

Failing them in the transform keeps them out of the batch: the valid
events go out on the first request, no extra per-job requests are made,
and the failure shows in Live Events with a message naming the missing
field. The 400 delivery handling is unchanged and still covers any other
rejection.

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

- Impressions and clicks without `resolvedBidId` or `entity` now fail in
the transform instead of at Topsort.
- A purchase line with no price was previously sent (#5808 kept it),
which made Topsort reject the whole purchase. It is now dropped, so the
purchase's priced lines are delivered.

Everything that now fails or is dropped was already rejected by Topsort,
so nothing that used to be delivered stops being delivered. Purchases
with an unpriced line go from fully rejected to delivered without that
line.

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

Fewer requests to Topsort: these events no longer cause a rejected batch
followed by one request per job.

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
ItsSudip added a commit that referenced this pull request Nov 23, 2026
…5826)

> **Contributed by @bernirosas in #5818** (fork PR). This PR brings
their commits from `contrib/5818` 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 no longer sends events or purchase lines that
the Topsort Events API always rejects with a 400.

| Event | Topsort's 400 | Now |
| --- | --- | --- |
| Impression or click with neither `properties.resolvedBidId` nor
`properties.entity` | `Entity ... failed on the 'required_without' tag`
| Fails with a 400 (`InstrumentationError`), not sent |
| Purchase line with no price, or a non-numeric one | `UnitPrice ...
failed on the 'required' tag` | The line is dropped, like a zero-priced
one; the rest of the purchase is sent |
| Purchase with no priced line left | `UnitPrice ...` /
`no_purchase_items` | Fails with a 400 (`InstrumentationError`), not
sent. All lines priced 0 is still skipped as filtered (298), as before |

- Sponsored events (with `resolvedBidId`) and organic events (with
`entity`) are unchanged.
- The check covers every event a message fans out to over `products`,
since both fields come from the message.
- Zero-priced lines are still dropped as before (#5808).

## What is the related Linear task?

N/A

## Please explain the objectives of your changes below

Both rejections were observed on live Events API traffic, for clicks and
purchase lines. No impression without `entity` showed up in that
traffic, so the impression case follows the API reference (impressions
and clicks share the same `resolvedBidId`/`entity` requirement) rather
than an observed 400. Because the Events API rejects a whole request for
one bad event, each of these events currently:

1. rejects the batch it is in, and
2. triggers the 400 handler's `dontBatch` retry, so every job in that
batch is re-sent on its own before the bad one is finally aborted.

Failing them in the transform keeps them out of the batch: the valid
events go out on the first request, no extra per-job requests are made,
and the failure shows in Live Events with a message naming the missing
field. The 400 delivery handling is unchanged and still covers any other
rejection.

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

- Impressions and clicks without `resolvedBidId` or `entity` now fail in
the transform instead of at Topsort.
- A purchase line with no price was previously sent (#5808 kept it),
which made Topsort reject the whole purchase. It is now dropped, so the
purchase's priced lines are delivered.

Everything that now fails or is dropped was already rejected by Topsort,
so nothing that used to be delivered stops being delivered. Purchases
with an unpriced line go from fully rejected to delivered without that
line.

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

Fewer requests to Topsort: these events no longer cause a rejected batch
followed by one request per job.

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

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Bernardita Rosas <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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