<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Webhook Drift Scanner</title>
    <description>The latest articles on DEV Community by Webhook Drift Scanner (@nmasaya24884byte).</description>
    <link>https://dev.to/nmasaya24884byte</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4103457%2F6a25ac8d-9279-4909-bc2c-4b261b6bedad.png</url>
      <title>DEV Community: Webhook Drift Scanner</title>
      <link>https://dev.to/nmasaya24884byte</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nmasaya24884byte"/>
    <language>en</language>
    <item>
      <title>A JSON diff is not a webhook contract test</title>
      <dc:creator>Webhook Drift Scanner</dc:creator>
      <pubDate>Tue, 01 Sep 2026 07:11:28 +0000</pubDate>
      <link>https://dev.to/nmasaya24884byte/a-json-diff-is-not-a-webhook-contract-test-3i9a</link>
      <guid>https://dev.to/nmasaya24884byte/a-json-diff-is-not-a-webhook-contract-test-3i9a</guid>
      <description>&lt;p&gt;When a webhook payload changes, a generic JSON diff can tell you that a value or path changed. It usually cannot tell you which change is likely to break a consumer, or give you a regression test for the code that consumes it.&lt;/p&gt;

&lt;p&gt;This matters most when your code assumes things such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a field always exists;&lt;/li&gt;
&lt;li&gt;a number will never become a string;&lt;/li&gt;
&lt;li&gt;a nested object will never become an array;&lt;/li&gt;
&lt;li&gt;a value cannot be &lt;code&gt;null&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;every item in an array has the same shape.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Start with the consumer, not the provider
&lt;/h2&gt;

&lt;p&gt;Suppose an old payload contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"customer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"email"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dev@example.test"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The new sample contains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"amount"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1200"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"customer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A syntax diff reports two changes. A consumer-oriented review asks different questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Does a decoder require &lt;code&gt;amount&lt;/code&gt; to be a number?&lt;/li&gt;
&lt;li&gt;Does application code read &lt;code&gt;customer.email&lt;/code&gt; without a fallback?&lt;/li&gt;
&lt;li&gt;Can a sanitized version of the new payload be kept as a regression fixture?&lt;/li&gt;
&lt;li&gt;Can the actual consumer/parser be executed against that fixture in CI?&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  What two samples can and cannot prove
&lt;/h2&gt;

&lt;p&gt;Two samples can reveal structural candidates:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;removed paths;&lt;/li&gt;
&lt;li&gt;scalar type changes;&lt;/li&gt;
&lt;li&gt;object/array/scalar shape changes;&lt;/li&gt;
&lt;li&gt;newly observed &lt;code&gt;null&lt;/code&gt; values;&lt;/li&gt;
&lt;li&gt;nested-path changes;&lt;/li&gt;
&lt;li&gt;array item shape changes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They cannot prove the provider's complete contract. In particular, they do not establish every required or optional field, all enum values, conditional variants, or every possible array item.&lt;/p&gt;

&lt;p&gt;That is why a useful scanner should say &lt;strong&gt;candidate&lt;/strong&gt;, not &lt;strong&gt;confirmed breaking change&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Turn the comparison into a test
&lt;/h2&gt;

&lt;p&gt;The most useful output is not another diff screen. It is a sanitized fixture and a test that you can adapt to call the real consumer:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nf"&gt;describe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;webhook contract drift&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;test&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;the consumer accepts the reviewed fixture&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;consumeWebhook&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newFixture&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toMatchObject&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;expectedBusinessOutput&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The assertion should be about consumer behavior, not only JSON shape.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep production payloads out of unnecessary systems
&lt;/h2&gt;

&lt;p&gt;Webhook payloads can contain customer or operational data. For a one-off comparison, there is no need to upload them to a scanning backend. A browser-local tool can compare the two inputs and generate the fixture locally.&lt;/p&gt;

&lt;p&gt;You should still sanitize secrets and personal data before pasting them into any developer tool.&lt;/p&gt;

&lt;h2&gt;
  
  
  A small experimental tool
&lt;/h2&gt;

&lt;p&gt;I built an experimental browser-local scanner around this workflow. It compares old and new JSON samples, explains consumer-risk candidates, and generates a Jest/Vitest fixture test.&lt;/p&gt;

&lt;p&gt;It does not upload or store payload content, does not require an account, and does not claim to infer a complete provider contract.&lt;/p&gt;

&lt;p&gt;Try the free scanner: &lt;a href="https://nmasaya24884-byte.github.io/webhook-contract-drift-scanner/" rel="noopener noreferrer"&gt;https://nmasaya24884-byte.github.io/webhook-contract-drift-scanner/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source and limitations: &lt;a href="https://github.com/nmasaya24884-byte/webhook-contract-drift-scanner" rel="noopener noreferrer"&gt;https://github.com/nmasaya24884-byte/webhook-contract-drift-scanner&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The tool is an experiment. Feedback should focus on whether the consumer-impact explanation and generated test are useful—not on treating its output as a guarantee.&lt;/p&gt;




&lt;p&gt;Disclosure: This article was drafted with AI assistance and reviewed against the tool's implementation, tests, limitations, and DEV Community content guidelines before publication.&lt;/p&gt;

</description>
      <category>api</category>
      <category>webdev</category>
      <category>testing</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
