<?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: ahmedgcompany-cyber</title>
    <description>The latest articles on DEV Community by ahmedgcompany-cyber (@ahmedgcompanycyber).</description>
    <link>https://dev.to/ahmedgcompanycyber</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%2F4150192%2F88d13275-ed26-4ee9-a333-eae020568d10.jpeg</url>
      <title>DEV Community: ahmedgcompany-cyber</title>
      <link>https://dev.to/ahmedgcompanycyber</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ahmedgcompanycyber"/>
    <language>en</language>
    <item>
      <title>our tests mock the API. The API changed anyway. tags: api, devops, opensource, ai</title>
      <dc:creator>ahmedgcompany-cyber</dc:creator>
      <pubDate>Tue, 29 Sep 2026 15:49:44 +0000</pubDate>
      <link>https://dev.to/ahmedgcompanycyber/our-tests-mock-the-api-the-api-changed-anywaytags-api-devops-opensource-ai-47i4</link>
      <guid>https://dev.to/ahmedgcompanycyber/our-tests-mock-the-api-the-api-changed-anywaytags-api-devops-opensource-ai-47i4</guid>
      <description>&lt;p&gt;In the last year, some of the most frustrating production issues I've seen weren't outages. The dependency was up.&lt;br&gt;
It returned &lt;code&gt;200 OK&lt;/code&gt;. It just didn't return the same thing anymore.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A field our code relied on was removed from a well-known API's payload.&lt;/li&gt;
&lt;li&gt;An LLM provider started rejecting a request format that was valid the week before; the SDK types still allowed it.&lt;/li&gt;
&lt;li&gt;A model alias quietly pointed at a new snapshot, and our support bot's tone changed overnight.&lt;/li&gt;
&lt;li&gt;A remote MCP server added a required parameter to a tool, and every agent calling it started failing.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Why our safety nets missed it
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Unit tests&lt;/strong&gt; mock the response shape we saw when we wrote them. &lt;strong&gt;Integration tests&lt;/strong&gt; run on pull requests, not when&lt;br&gt;
the provider deploys. &lt;strong&gt;Uptime monitors&lt;/strong&gt; check the status code. &lt;strong&gt;APM&lt;/strong&gt; sees a trickle of 4xx errors and files them&lt;br&gt;
under "client error". Nothing is watching the &lt;em&gt;contract&lt;/em&gt; between us and the provider.&lt;/p&gt;
&lt;h2&gt;
  
  
  Watching the contract
&lt;/h2&gt;

&lt;p&gt;The approach I ended up with:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Probe on a schedule&lt;/strong&gt; with real (authenticated) requests.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Learn a structural baseline&lt;/strong&gt; from the first N successful responses: every JSON path and the types seen there,
and whether it was always present.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Diff each new response&lt;/strong&gt; against the baseline and classify:

&lt;ul&gt;
&lt;li&gt;a field that was always present is gone → &lt;strong&gt;breaking&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;a type changed (number → string, object → array) → &lt;strong&gt;breaking&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;a field is newly &lt;code&gt;null&lt;/code&gt; → &lt;strong&gt;warning&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;a new field appeared → &lt;strong&gt;info&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Track a few exact values&lt;/strong&gt; that matter: the model an LLM provider reports, an MCP tool's required parameters.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Deduplicate&lt;/strong&gt; by fingerprinting the change set, and let a human &lt;strong&gt;accept&lt;/strong&gt; (update the baseline) or &lt;strong&gt;dismiss&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gate deploys&lt;/strong&gt; on unreviewed breaking drift.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Details that turned out to matter: don't report children of a field that became &lt;code&gt;null&lt;/code&gt; (report the parent once); don't&lt;br&gt;
report elements of arrays that were always empty in the baseline; let users ignore paths like maps keyed by IDs.&lt;/p&gt;
&lt;h2&gt;
  
  
  Keys stay home
&lt;/h2&gt;

&lt;p&gt;Monitoring authenticated endpoints means the monitor holds your API keys. That was the reason I built this as a&lt;br&gt;
self-hosted tool: secrets are encrypted at rest (AES-256-GCM, rotatable), never returned by the API, and every outbound&lt;br&gt;
request goes through an SSRF guard.&lt;/p&gt;
&lt;h2&gt;
  
  
  Try it
&lt;/h2&gt;

&lt;p&gt;ContractRift is open source (AGPL-3.0): &lt;a href="https://github.com/ahmedgcompany-cyber/contractrift" rel="noopener noreferrer"&gt;https://github.com/ahmedgcompany-cyber/contractrift&lt;/a&gt; — live demo: &lt;a href="https://136-119-147-140.sslip.io" rel="noopener noreferrer"&gt;https://136-119-147-140.sslip.io&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 3000:3000 &lt;span class="nt"&gt;-v&lt;/span&gt; contractrift:/data &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;ENCRYPTION_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;openssl rand &lt;span class="nt"&gt;-base64&lt;/span&gt; 32&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  ghcr.io/ahmedgcompany-cyber/contractrift:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I'd love to hear where the drift rules produce false positives on the APIs you use.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
