Skip to content

fix(ms-bing-capi): do not fail batched events on validation warnings#3863

Open
scottlepich-lz wants to merge 1 commit into
segmentio:mainfrom
scottlepich-lz:fix/ms-bing-capi-batch-warning-not-error
Open

fix(ms-bing-capi): do not fail batched events on validation warnings#3863
scottlepich-lz wants to merge 1 commit into
segmentio:mainfrom
scottlepich-lz:fix/ms-bing-capi-batch-warning-not-error

Conversation

@scottlepich-lz

Copy link
Copy Markdown

Summary

The Microsoft Bing CAPI sendEvent action sends events with continueOnValidationError: true, which means 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 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 perform path returns the raw 200 response, so the bug only manifested in batching.

Example real response detail (Microsoft returns 200 with):

{ "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 marked 400. continueOnValidationError: true and the perform/performBatch structure are unchanged.
  • types.ts: extended the MSMultiStatusResponse.error.details[] element type with the fields the API actually returns (isWarning?: boolean, errorCode?: string).

No generated-types.ts change — this is response handling, not fields.

Testing

Added performBatch unit tests proving:

  • a 200 response with an isWarning: true detail at an event's index -> that event is a SUCCESS (200), not a 400;
  • a real error detail (isWarning: false) at an index -> that event is still marked 400, while a warning at a different index stays 200;
  • an error detail with no isWarning field -> 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.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change. (No new fields; a fix to existing response handling.)
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

Security Review

  • Reviewed all field definitions for sensitive data — no field definitions changed in this PR.

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

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>
Copilot AI review requested due to automatic review settings July 7, 2026 19:19
@scottlepich-lz scottlepich-lz requested a review from a team as a code owner July 7, 2026 19:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 with isWarning: true
  • Extend the multi-status response detail typings with errorCode and isWarning
  • 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.

Comment on lines 61 to 66
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)
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.

2 participants