Public Beta: Direct engineering support available. Join Discord →
Guides
Why is my webhook data wrong after the transform?

Why is my webhook data wrong after the transform?

Because the transform was checked against a payload you imagined, not the ones you actually receive. Keep the raw payload of every event, run the transform against a set of real stored payloads with the output you expect for each, and diff field by field: the first field that differs names the mapping to fix. Fix it, re-run the same set until it is clean, and only then reprocess the events that went through the broken version.

A field-by-field check

// Run a transform against real stored payloads and report every field that differs.
// cases: [{ name, input, expected }] where input is a raw payload you actually received
export function checkTransform (transform, cases) {
  const failures = []
  for (const { name, input, expected } of cases) {
    let actual
    try { actual = transform(structuredClone(input)) } catch (err) { failures.push({ name, error: String(err) }); continue }
    const diffs = []
    const walk = (exp, act, path) => {
      if (exp !== null && typeof exp === 'object') {
        const keys = new Set([...Object.keys(exp), ...Object.keys(act ?? {})])
        for (const k of keys) walk(exp[k], act?.[k], path ? `${path}.${k}` : k)
      } else if (exp !== act) diffs.push({ path, expected: exp, actual: act })
    }
    walk(expected, actual, '')
    if (diffs.length) failures.push({ name, diffs })
  }
  return failures
}

Where the cases come from

From payloads you received, not from the sender's documentation. Take one per event type, and add one every time a payload surprises you: a null where you expected a string, an amount sent as text, an optional object that is absent. Each becomes a case whose expected output you write by hand once.

Then reprocess the damage

Events that went through the broken transform are wrong in your store. Once the check is clean, re-run the stored raw payloads from the window the bug was live through the fixed transform — replay does that in Slashbin without asking the sender to resend anything.

Seeing it before you ship it

Slashbin's Transformation IDE puts the raw inbound payload, your transformation logic and a live preview of the output side by side, so a wrong field shows up while you write the mapping rather than in a customer's report.

Need somewhere for the next project's webhooks to land? Slashbin's Free plan takes an account, not a card.

Start Free

(opens in a new tab)

Related