Skip to content

feat(http): support XML and FORM bodies in v2 router - #5768

Merged
shekhar-rudder merged 5 commits into
developfrom
harness/INT-7520-feat-http-support-xml-and-form-c9c6743e
Nov 10, 2026
Merged

shekhar-rudder merged 5 commits into
developfrom
harness/INT-7520-feat-http-support-xml-and-form-c9c6743e

Conversation

@rudder-devbox

@rudder-devbox rudder-devbox Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

What are the changes introduced in this PR?

HTTP v2 now serializes XML and FORM bodies with v1 wire-format parity, including XML batching and single-event FORM requests. It follows the merged v2 definition (rudder-integrations-config #2890): there is no xmlRootKey; for XML the template produces one object with exactly one top-level key, which becomes the root element.

What is the related Linear task?

Resolves INT-7520

Please explain the objectives of your changes below

Deploy this transformer to every region before integrations-config exposes XML/FORM; otherwise older data planes may send JSON to XML/FORM endpoints. Control-plane, webapp, Terraform, and CLI changes are separate.

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

HTTP v2 accepts an optional format; JSON remains the default. XML/FORM require an object template result. XML additionally requires exactly one top-level key holding an object; the key is sanitized like nested keys and used as the root element. FORM is always single-event. XML batches use the wrapped form, e.g. {"Envelope": {"event": [$$.events.{...}]}}.

Any new dependencies introduced with this change?

None.

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

None. The shared JSONata validator is unchanged; sanitizeKey is now exported from the v1 HTTP utils so v2 can sanitize the XML root element.

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

HTTP secret paths were regenerated for review and were unchanged. FORM ignores stale batch-size values above one.

Validation

  • npm test -- --testPathPattern='jsonataTemplate|http|controllers/__tests__/eventTest|custom_audience/template' --no-coverage --runInBand: 7 suites, 166 tests passed.
  • npm run test:ts -- component --destination=http --runInBand: 20 tests passed.
  • npm run build:ci, npx tsc --noEmit -p tsconfig.test.json, targeted Prettier and ESLint, and git diff --check: passed.
  • HTTP secret-path generation passed and derived the unchanged headers path. The repository-wide npm run lint exceeded the command wait window; targeted formatting and lint passed.
  • Code-simplify: clarified the AST exception name and comment; no worthwhile reuse or efficiency changes.

⚠️ Known Issues

  • The mini transformer is a sha-pinned stock image, so this source change was not live-verified there; unit and component coverage remains the observed signal.
  • D1–D8 remain draft decisions and must be ratified before release.
  • Repository-wide npm run lint exceeded the command wait window; targeted ESLint and formatting passed.
  • XML/FORM exposure depends on deploying this transformer in every region before the v2 definition is released.

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.

⚠️ Auto-review unresolved

Adversarial self-review surfaced findings that were not auto-fixed. Each carries its disposition — please evaluate before merging.

  • high: Split FORM body evaluation into bounded sandbox calls — src/v0/destinations/http/routerTransform.ts:91 — not auto-fixed (iteration budget exhausted)

🔭 Live preview

Resumable while this task is open.

@coderabbitai

coderabbitai Bot commented Nov 5, 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: ed90577e-f70c-4512-bd95-4e63ae1fa2b6

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

@rudder-devbox

rudder-devbox Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

👋 I'm rudder-devbox. I opened this PR from task INT-7520.

Mention @devbox or @rudder-devbox and I'll act on it — on a top-level PR comment,
in a review summary, or on an inline comment on the diff. Without a mention I won't see it.

- Reuse BodyFormat and isObject instead of v1's CONTENT_TYPES_MAP and a
  hand-rolled object check; fold the format default into destructuring.
- Drop the unreachable try/catch around prepareBody (input is sandbox-cloned
  plain JSON).
- Drop a dead path-predicate condition from the first-event check.
- Reset objectPropertyValue when walking $number() arguments so the XML
  unwrapped-mapping exemption no longer leaks into function calls.
- Remove duplicate template tests and the mocked controller test that
  asserted nothing new; split the XML/FORM serializer test.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 92.45%. Comparing base (5b82078) to head (75e8a6b).
⚠️ Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
src/v0/destinations/http/routerTransform.ts 96.77% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #5768      +/-   ##
===========================================
+ Coverage    92.44%   92.45%   +0.01%     
===========================================
  Files          741      741              
  Lines        41119    41174      +55     
  Branches      9675     9691      +16     
===========================================
+ Hits         38013    38068      +55     
- Misses        2845     2923      +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.

@rudder-devbox

rudder-devbox Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

I traced the failure to the unchanged Everflow live scenario, everflow-track-conversion / deliver conversion. The proxy returned HTTP 200, but Everflow returned a bodyless 204; the test correctly recorded verdict.status 204 and Everflow rejected the conversion. Its separate random-transaction rejection case passed.

This branch changes HTTP v2 and the shared JSONata validator, not Everflow. The shared edit caused CI to include Everflow in the live matrix. The success scenario uses a transaction ID from the external LIVE_SECRET_EVERFLOW secret, and Everflow returned no reason for rejecting it. The Everflow conversion report and that test transaction need checking outside this repository. I made no code change or push; treating 204 as success would hide a rejected conversion.

Drop the new filter check on array constructors. The migration templates
`[$$.events][0]` and `[$$.events.{...}][0]` already validate on develop, so
HTTP does not need it, and it changed validation for the custom audience
`records` collection, which is outside this change.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rudder-devbox

rudder-devbox Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

This run repeats the Everflow live-test failure: everflow-track-conversion / deliver conversion received proxy HTTP 200 but verdict.status 204, with Everflow rejected the conversion; the random-transaction rejection test passed. Everflow returned no error detail.

The current branch changes HTTP v2 and the shared JSONata validator, not Everflow. The successful Everflow scenario uses resourceIds.transactionId from LIVE_SECRET_EVERFLOW. Its configured transaction and the Everflow conversion report need checking outside this repository before the live test can pass. I made no code change or push and left the 204 rejection assertion intact.

…efinition

The merged HTTP v2 definition drops `xmlRootKey`: for XML the template must
produce one object with exactly one top-level key, and that key is the root
element. The transformer enforces the one-key rule, sanitizes the root name
like nested keys (so a data-derived key cannot inject markup), and rejects an
empty root.

The shared JSONata validator is back to develop: XML batches use the wrapped
form `{"Root": {"event": [$$.events.{...}]}}`, which renders identical XML, so
the unwrapped-mapping exemption (which also let JSON templates through) is gone.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rudder-devbox

rudder-devbox Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

I found two separate live-test failures. Everflow’s deliver conversion again returned proxy HTTP 200 with verdict.status 204 and Everflow rejected the conversion, with no partner detail. Its configured transaction and conversion report need checking externally.

Intercom’s rETL identify (external_id + email, email-only contact exists) received a partner 409: A contact matching those details already exists. The test had created that contact and waited for search visibility, but the later transform lookup still missed it and attempted a conflicting create; the read-back failure is only a consequence of this step. The scenario already retries this eventual-consistency case.

This branch changes HTTP v2 and its JSONata validation, not Everflow or Intercom. The shared-file edit causes the workflow to run their live scenarios. I made no code change or push: both failures depend on external partner/test-account state, and weakening their delivery assertions would hide real rejections.

- Handle JSON first so XML/FORM shaping reads as flat early returns.
- Type v1 prepareBody's result as an object (it never returns a string),
  removing the HttpBody casts; restore the maxBatchSize string comment.
- Merge the XML/FORM rejection tables into one; drop unit tests that repeat
  the component fixtures or the existing bad-cast chunk test, and the sandbox
  client tests that no longer exercise anything this change touches.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@rudder-devbox

rudder-devbox Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

The failed job is the unchanged Everflow success scenario: everflow-track-conversion / deliver conversion received proxy HTTP 200 but verdict.status 204, and the response says Everflow rejected the conversion with no detail. The random-transaction rejection scenario passed. This is the same partner rejection seen in prior runs.

The branch changes HTTP v2 and an HTTP serializer export; it does not change Everflow. The HTTP serializer path causes the live workflow to run its full matrix, exposing this external test-data failure. The Everflow conversion report and the transaction ID in LIVE_SECRET_EVERFLOW need checking and, if necessary, refreshing. I made no code change or push and left the rejection assertion intact.

@sonarqubecloud

Copy link
Copy Markdown

@shekhar-rudder
shekhar-rudder marked this pull request as ready for review November 10, 2026 09:07
@shekhar-rudder
shekhar-rudder requested review from a team as code owners November 10, 2026 09:07
Copilot AI balanced review requested due to automatic review settings November 10, 2026 09:07

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.

🟡 Changes recommended

FORM evaluates all event chunks in a single sandbox call with a shared 500 ms budget, so large groups can repeatedly fail on retry; bounded calls and a multi-page regression test are needed.

1 open issue
What changed in this PR

Adds XML and FORM body support to the HTTP v2 router using existing v1 serializers, while keeping JSON as the default.

Changes:

  • Adds optional format configuration and format-specific content types.
  • Supports template-defined XML roots and batching; forces FORM requests to contain one event.
  • Adds unit and component coverage for serialization, validation, and batching behavior.
File Description
test/​integrations/​destinations/​http/​router/​data.ts Adds XML batch and single-event FORM component cases.
test/​integrations/​destinations/​http/​common.ts Adds shared XML and FORM destination fixtures.
src/​v0/​destinations/​http/​types.ts Accepts optional JSON, XML, or FORM configuration.
src/​v0/​destinations/​http/​routerTransform.ts Implements format-specific serialization, validation, headers, and batching.
src/​v0/​destinations/​http/​routerTransform.test.ts Tests serialization edge cases and invalid template results.
src/​cdk/​v2/​destinations/​http/​utils.ts Exports the shared key sanitizer and narrows the body type.

Review effort: Balanced

@shekhar-rudder
shekhar-rudder merged commit f4d5d8d into develop Nov 10, 2026
53 of 54 checks passed
@shekhar-rudder
shekhar-rudder deleted the harness/INT-7520-feat-http-support-xml-and-form-c9c6743e branch November 10, 2026 09:23
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