fix(ms-bing-capi): do not fail batched events on validation warnings - #3863
fix(ms-bing-capi): do not fail batched events on validation warnings#3863scottlepich-lz wants to merge 2 commits into
Conversation
The sendEvent action sends events with `continueOnValidationError: true`, so Microsoft's CAPI accepts an event (HTTP 200, `eventsReceived: 1`) even when it has non-fatal issues, and reports those issues as entries in `error.details[]` flagged with `"isWarning": true`. The batch response handler (`performBatch`) matched `error.details[]` by `index` only and treated ANY matching detail as a hard failure. As a result, a batched event whose only detail was a warning was marked `status: 400` and reported as a failed delivery, even though Microsoft had accepted it. This caused real, silent delivery failures for any batched event that triggered a Microsoft warning. (Single `perform` returns the raw 200, so the bug only manifested in batching.) Fix: only treat a detail as a failure when it is NOT a warning (`detail.index === index && !detail.isWarning`). A warning-only event is now marked SUCCESS (200); an event with a real (non-warning) error at its index is still marked 400. `types.ts` is extended to model the `isWarning` and `errorCode` fields the API actually returns. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because no GitHub Actions runner was available. Make sure your repository has a runner available to run Copilot's review, or add a copilot-setup-steps.yml file specifying one with the runs-on attribute. See the docs for more details.
Fixes batched sendEvent handling for Microsoft Bing CAPI responses so that validation warnings (accepted events) don’t get incorrectly reported as failed deliveries.
Changes:
- Update batch error matching to ignore
error.details[]entries flagged withisWarning: true - Extend the multi-status response detail typings with
errorCodeandisWarning - Add unit tests covering warning-only vs non-warning detail behavior in batch responses
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/ms-bing-capi/sendEvent/types.ts | Extends response typings to include errorCode / isWarning on error.details[] entries. |
| packages/destination-actions/src/destinations/ms-bing-capi/sendEvent/index.ts | Adjusts batch indexing logic to treat warning-only details as success. |
| packages/destination-actions/src/destinations/ms-bing-capi/sendEvent/tests/sendEvent.test.ts | Adds batch unit tests to prevent regressions around warning vs error detail handling. |
| propertyName: string | ||
| attemptedValue: unknown | ||
| errorMessage: string | ||
| errorCode?: string | ||
| isWarning?: boolean | ||
| }> |
|
|
||
| payloads.forEach((payload, index) => { | ||
| const error = details.find((detail) => detail.index === index) | ||
| const error = details.find((detail) => detail.index === index && !detail.isWarning) |
| .reply(200, { | ||
| eventsReceived: 1, | ||
| error: { |
|
|
||
| payloads.forEach((payload, index) => { | ||
| const error = details.find((detail) => detail.index === index) | ||
| const error = details.find((detail) => detail.index === index && !detail.isWarning) |
|
Superseded by #3859. The batch-warning fix ( |
Summary
The Microsoft Bing CAPI
sendEventaction sends events withcontinueOnValidationError: true, which means Microsoft's CAPI accepts an event (HTTP200,eventsReceived: 1) even when it has non-fatal issues, and reports those issues as entries inerror.details[]flagged with"isWarning": true.The batch response handler (
performBatch) matchederror.details[]byindexonly and treated ANY matching detail as a hard failure. As a result, a batched event whose only detail was a warning was markedstatus: 400and reported back to Segment as a failed delivery, even though Microsoft had already accepted it. This caused real, silent delivery failures for any batched event that triggered a Microsoft warning.The single-event
performpath returns the raw200response, so the bug only manifested in batching.Example real response detail (Microsoft returns
200with):{ "errorCode": "Empty", "errorMessage": "'price' must not be empty.", "index": 0, "isWarning": true, "propertyName": "data[0].customData.items[0].price" }Fix
index.ts: only treat a detail as a failure when it is not a warning —details.find((detail) => detail.index === index && !detail.isWarning). A warning-only event is now marked SUCCESS (200); an event with a real (non-warning) error at its index is still marked400.continueOnValidationError: trueand theperform/performBatchstructure are unchanged.types.ts: extended theMSMultiStatusResponse.error.details[]element type with the fields the API actually returns (isWarning?: boolean,errorCode?: string).No
generated-types.tschange — this is response handling, not fields.Testing
Added
performBatchunit tests proving:200response with anisWarning: truedetail at an event's index -> that event is a SUCCESS (200), not a400;isWarning: false) at an index -> that event is still marked400, while a warning at a different index stays200;isWarningfield -> defaults to a real failure (400), preserving existing behavior.Ran only the ms-bing-capi tests (
jest src/destinations/ms-bing-capi): 18 passed, 18 total. Typecheck and ESLint on the changed files are clean; Prettier reports no formatting issues.Security Review
Related
Sibling to the item-price fix in #3859 (#3859), which addresses a separate issue in the same destination. This PR does not depend on or touch that change.
🤖 Generated with Claude Code