Skip to content

fix(topsort): fail events the Events API rejects before sending them - #5826

Merged
ItsSudip merged 1 commit into
developfrom
contrib/5818
Nov 23, 2026
Merged

ItsSudip merged 1 commit into
developfrom
contrib/5818

Conversation

@ItsSudip

Copy link
Copy Markdown
Member

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 (feat(topsort): drop zero-priced purchase lines #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 (feat(topsort): drop zero-priced purchase lines #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.


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?

🤖 Generated with Claude Code

…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]>
@coderabbitai

coderabbitai Bot commented Nov 23, 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: c1e55a7d-cf2f-4ccc-9f18-b8846607a5b0

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

@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.05%. Comparing base (3868891) to head (1ebe302).

Additional details and impacted files
@@            Coverage Diff            @@
##           develop    #5826    +/-   ##
=========================================
  Coverage    92.05%   92.05%            
=========================================
  Files          749      749            
  Lines        41973    41978     +5     
  Branches      9788     9902   +114     
=========================================
+ Hits         38638    38643     +5     
  Misses        3152     3152            
  Partials       183      183            

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

@ItsSudip
ItsSudip merged commit 9c52afa into develop Nov 23, 2026
38 checks passed
@ItsSudip
ItsSudip deleted the contrib/5818 branch November 23, 2026 16:28
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