<?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>Forem: specshield</title>
    <description>The latest articles on Forem by specshield (@specshield_a17bcb1ca84675).</description>
    <link>https://forem.com/specshield_a17bcb1ca84675</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3883005%2F3801d36c-f381-4627-8633-e340cd886945.png</url>
      <title>Forem: specshield</title>
      <link>https://forem.com/specshield_a17bcb1ca84675</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/specshield_a17bcb1ca84675"/>
    <language>en</language>
    <item>
      <title>We Broke Production Due to an API Change — Here's How I Fixed It</title>
      <dc:creator>specshield</dc:creator>
      <pubDate>Thu, 16 Apr 2026 18:15:42 +0000</pubDate>
      <link>https://forem.com/specshield_a17bcb1ca84675/we-broke-production-due-to-an-api-change-heres-how-i-fixed-it-42en</link>
      <guid>https://forem.com/specshield_a17bcb1ca84675/we-broke-production-due-to-an-api-change-heres-how-i-fixed-it-42en</guid>
      <description>&lt;p&gt;In a microservices architecture, one small API change can break multiple downstream systems.&lt;/p&gt;

&lt;p&gt;I learned this the hard way.&lt;/p&gt;




&lt;h2&gt;
  
  
  💥 The Problem
&lt;/h2&gt;

&lt;p&gt;We had a backend service that modified an API:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A field was removed&lt;/li&gt;
&lt;li&gt;Response structure slightly changed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything passed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unit tests ✅&lt;/li&gt;
&lt;li&gt;Integration tests ✅&lt;/li&gt;
&lt;li&gt;Code review ✅&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But in production:&lt;br&gt;
👉 Another service broke.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because we never enforced API contracts.&lt;/p&gt;


&lt;h2&gt;
  
  
  🔍 Root Cause
&lt;/h2&gt;

&lt;p&gt;We relied on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Human review&lt;/li&gt;
&lt;li&gt;Documentation&lt;/li&gt;
&lt;li&gt;Assumptions of backward compatibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But we were missing:&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Automated contract validation&lt;/strong&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  💡 The Solution
&lt;/h2&gt;

&lt;p&gt;I built a simple approach:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Store OpenAPI spec (baseline)&lt;/li&gt;
&lt;li&gt;Compare new spec during CI&lt;/li&gt;
&lt;li&gt;Fail build if breaking changes detected&lt;/li&gt;
&lt;/ol&gt;


&lt;h2&gt;
  
  
  ⚙️ Implementation
&lt;/h2&gt;

&lt;p&gt;Using a CLI approach:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx specshield compare old.yaml new.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CI Integration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Check API breaking changes&lt;/span&gt;
  &lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;npx specshield compare&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  🚨 What counts as breaking?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Removing endpoints&lt;/li&gt;
&lt;li&gt;Removing fields&lt;/li&gt;
&lt;li&gt;Changing types&lt;/li&gt;
&lt;li&gt;Making optional → required&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🧠 Key Learnings
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;API contracts should be treated like code&lt;/li&gt;
&lt;li&gt;CI is the best place to enforce safety&lt;/li&gt;
&lt;li&gt;Even small changes can have big impact&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🔮 Future Improvements
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Consumer-driven contracts (Pact-style)&lt;/li&gt;
&lt;li&gt;Better diff visualization&lt;/li&gt;
&lt;li&gt;Integration with GitHub PR checks&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🤔 How do you handle this?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Do you use OpenAPI validation?&lt;/li&gt;
&lt;li&gt;Pact?&lt;/li&gt;
&lt;li&gt;Custom scripts?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Curious to learn how others solve this problem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://specshield.io/" rel="noopener noreferrer"&gt;https://specshield.io/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>api</category>
      <category>cicd</category>
      <category>microservices</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
