<?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: Tomasz Jędrzejewski</title>
    <description>The latest articles on DEV Community by Tomasz Jędrzejewski (@zyxist).</description>
    <link>https://dev.to/zyxist</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%2F4224880%2F99fd93ed-ca96-409b-9e9e-de6f60c74d57.jpg</url>
      <title>DEV Community: Tomasz Jędrzejewski</title>
      <link>https://dev.to/zyxist</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zyxist"/>
    <language>en</language>
    <item>
      <title>Two Bugs, Zero Clues: How AI Saved Me Days of Debugging My API</title>
      <dc:creator>Tomasz Jędrzejewski</dc:creator>
      <pubDate>Fri, 13 Nov 2026 09:15:42 +0000</pubDate>
      <link>https://dev.to/zyxist/two-bugs-zero-clues-how-ai-saved-me-days-of-debugging-my-api-58j</link>
      <guid>https://dev.to/zyxist/two-bugs-zero-clues-how-ai-saved-me-days-of-debugging-my-api-58j</guid>
      <description>&lt;p&gt;Until recently, I thought the worst type of bugs were the ones that happen only in production. Now I know that there's something worse: bugs that happen only in production &lt;strong&gt;and&lt;/strong&gt; the only clue you have is &lt;em&gt;"there's an error"&lt;/em&gt; message. This is exactly what happened to me recently. I've been working on a side project: an API for city information and reverse geocoding. Everything went fine locally: creating spec, implementation, testing, dataset preparation, refinement... the API is nice, but it's not a rocket science, so I did not expect any further issues. The deployment should be quick. But it wasn't. &lt;em&gt;"Internal Server Error, Happy Debugging, Good Luck"&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I use AI in this project
&lt;/h2&gt;

&lt;p&gt;I'm using agentic coding and Spec-Driven Development (SDD) to build my API-s. That's my personal goal for it - I know how to write a code, I've been doing this for the last 20 years. What I'm exploring is how specs translate to the final product, how it affects engineering and engineering decisions.&lt;/p&gt;

&lt;p&gt;Until approx. a year ago, I hated agentic coding. The quality of the generated code was so poor that I spent more time on fixing the code than I saved. If something wastes my time, I don't like it. Simple. But this has changed, when a new generation of models arrived. Actually, before I gave the agentic coding another try (this time successfully), I firstly noticed the change in the code reviews. One day, the agent found an actual issue in my PR. Then another one, and another. This matters for me - code review is a skill, and many experienced developers suffer, because they often work with people who don't have it, so in turn - nobody does &lt;em&gt;proper&lt;/em&gt; code reviews for them :). And I also make bugs.&lt;/p&gt;

&lt;p&gt;I mention code reviews on purpose, because they have a lot in common with debugging the actual production issues. That's why I decided to engage the agent into solving my production bugs. Let's get into them!&lt;/p&gt;

&lt;h2&gt;
  
  
  Bug 1: A problem with production database
&lt;/h2&gt;

&lt;p&gt;I deployed the API to the production server and started testing. One endpoint worked as expected. The two others - did not:&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="nl"&gt;"error"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"Internal Server Error"&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I did not panic, because the endpoint was intentionally configured not to reveal error details. I obtained it from the detailed logs, and then I got really confused:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SQLSTATE[25000]: Invalid transaction state:
1207 Update locks cannot be acquired during
a READ UNCOMMITTED transaction
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is a read-only API. All queries are &lt;code&gt;SELECT&lt;/code&gt; queries, so where did this "update" and "transactions" come from? And why only in production? The same code worked well locally. Obviously there was something wrong with the production database setup, but what?&lt;/p&gt;

&lt;p&gt;I started with asking my coding agent:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Cities API - I deployed the Cities API to the production server, and the &lt;code&gt;reverse&lt;/code&gt; + &lt;code&gt;nearby&lt;/code&gt; endpoints respond with the following SQL error: (error here) The &lt;code&gt;search&lt;/code&gt; endpoint works as expected. The error does not occur locally. What can be wrong there?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The agent responded:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;No isolation level is set here — it inherits whatever the server's default &lt;code&gt;transaction_isolation&lt;/code&gt; is. That's the smoking gun. What's happening: &lt;code&gt;candidatesInBoundingBox()&lt;/code&gt; runs &lt;code&gt;MBRContains(ST_GeomFromText(:envelope, 4326), c.location)&lt;/code&gt; — this is the only query path used by &lt;code&gt;reverse&lt;/code&gt;/&lt;code&gt;nearby&lt;/code&gt; that touches the &lt;code&gt;location&lt;/code&gt; column's &lt;strong&gt;SPATIAL INDEX&lt;/strong&gt;. &lt;code&gt;search&lt;/code&gt; never touches it, which is exactly why &lt;code&gt;search&lt;/code&gt; works and &lt;code&gt;reverse&lt;/code&gt;/&lt;code&gt;nearby&lt;/code&gt; don't. InnoDB's spatial (R-tree) indexes can't do a plain MVCC consistent read — a lookup against them needs to take predicate/page locks to keep the R-tree structurally consistent. Under &lt;code&gt;READ UNCOMMITTED&lt;/code&gt;, InnoDB refuses to take any locks for a read, so it can't satisfy that requirement and MariaDB raises error &lt;code&gt;1207 ("Update locks cannot be acquired during a READ UNCOMMITTED transaction")&lt;/code&gt;. This is a documented MariaDB/InnoDB limitation: spatial indexes are only usable above &lt;code&gt;READ UNCOMMITTED&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The agent suggested setting the transaction isolation level manually. It did not solve the issue, but the direction was good, so I kept grilling. The agent then focused on the server deployment. It knew the vendor behind the production server and came back with a story about MariaDB and Galera setup that - supposedly - broke the spatial index functionality. But I challenged that, knowing that other spatial queries work, including &lt;em&gt;other&lt;/em&gt; bounding box queries:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Can you provide sources about Galera cluster and the issue details? The problem is that I successfully ran the bounding box query via phpMyAdmin in the production server.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I got the answer:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I was wrong about Galera — no verified source backs that, and I should have said so rather than asserting it. Retracting it. The real cause is a confirmed MariaDB bug. &lt;code&gt;MDEV-26123 — Using Spatial Indexes results in "Update locks cannot be acquired during a READ UNCOMMITTED transaction"&lt;/code&gt;. Affected versions: 10.2.39, 10.3.30, 10.4.20, 10.5.11, 10.6.1 — fix targeted for 10.11. (...) This maps onto our code: (...)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I cross-checked the verdict by pasting the error message in the Google, and I found references to the same bug on StackOverflow. The only thing that did not match was MariaDB actually did not fix it in version 10.11. But that was enough to spot the problem. The bug reference contained the list of workarounds to try out, until one works. The combination of upgrading MariaDB + adding &lt;code&gt;SQL_NO_CACHE&lt;/code&gt; to the query did the job and the problem was gone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verdict
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hopeless without agent?&lt;/strong&gt; Actually, no. If you paste the same error into Google, you quickly get the bug ID.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Added value&lt;/strong&gt;: The agent combined the bug ID with the actual queries in the code, and correctly identified why one endpoint works, and two others do not. This is the place where I saved a lot of time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent performance&lt;/strong&gt;: The agent hallucinated a bit, but it was due to my actions. I intentionally did not give the agent the access to the production server, but I never explained the limitations and the rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lesson learned&lt;/strong&gt;:

&lt;ul&gt;
&lt;li&gt;In such issues, understanding the production setup is important. Even if the agent does not have the access to the server, I &lt;em&gt;do have&lt;/em&gt; such access and I can check/test something - I just need to know what, and I could have told the agent to ask me to do it. In human-to-human communication, we should avoid forcing others to guess our intents, the same applies to the agents.&lt;/li&gt;
&lt;li&gt;If some explanation sounds suspicious, ask for sources.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Bug 2: error while publishing the API
&lt;/h2&gt;

&lt;p&gt;I list my API-s in one of the API marketplaces. The publishing process involves importing my OpenAPI Definition and generating:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An editable description of the API and endpoints in Markdown format.&lt;/li&gt;
&lt;li&gt;The schemas of input and output request/response JSON-s, which look like JSON Schema with some custom extensions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After a successful import and fixing some descriptions, I proceeded to testing the integration. And again: two endpoints worked, the third one did not:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Validation failed.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Yes, that was the whole error. No more clues, no access to the server or the source code. I made a mistake here: I tried to solve the problem on my own. Obviously I failed. There was certainly a bug on the gateway side, but without access to the source code, all I could do was writing to the support team. The next day, a weird idea came to my mind: why not asking the agent to solve it? What do am I losing? Nothing.&lt;/p&gt;

&lt;p&gt;Just like before, the agent did not have the access to the server. But this time, I prepared the data samples and explained the limitations to the agent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;example.json&lt;/code&gt; - example response from my API&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;input-schema.json&lt;/code&gt; and &lt;code&gt;output-schema.json&lt;/code&gt; - schemas copy-pasted from the publishing tool&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Prompt:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I need help examining the bug on the API gateway. How it works: it uses custom input and output schema definitions for requests and responses, converted from our OpenAPI Definition. When I run the test for &lt;code&gt;nearby&lt;/code&gt; endpoint, I constantly get &lt;code&gt;validation failed&lt;/code&gt; error with no further details (tried out multiple times on multiple fix attempts). In &lt;code&gt;/{directory}/&lt;/code&gt; you can find input and output schema definitions and an example response. You have no details about the error and the schema structure is custom. Please analyze them - maybe you will spot some issue that I miss? I suspect that this is a bug on the gateway side, but if we could create a workaround, this would be great. Outcome: suggestions of possible issues to review. If I see that it may be the cause, I will ask you to create an updated schema, so that I can try it out.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The agent replied:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Confirmed: &lt;code&gt;openapi/cities-v1.yaml&lt;/code&gt; defines &lt;code&gt;Radius&lt;/code&gt; using the OpenAPI 3.0 / JSON Schema draft-4 &lt;strong&gt;boolean&lt;/strong&gt; form — &lt;code&gt;exclusiveMinimum: true&lt;/code&gt; paired with &lt;code&gt;minimum: 0&lt;/code&gt; — and that's copied verbatim into &lt;code&gt;{directory}/input-schema.json&lt;/code&gt;. This is the only parameter across all three endpoints (&lt;code&gt;nearby&lt;/code&gt;, &lt;code&gt;reverse&lt;/code&gt;, &lt;code&gt;search&lt;/code&gt;) that uses &lt;code&gt;exclusiveMinimum&lt;/code&gt; at all; &lt;code&gt;reverse&lt;/code&gt; and &lt;code&gt;search&lt;/code&gt; have no equivalent field and don't exhibit this pattern.&lt;/p&gt;

&lt;p&gt;That matters because JSON Schema 2019-09+/2020-12 (what most "custom" schema validators, including the one on the marketplace, actually implement) requires &lt;code&gt;exclusiveMinimum&lt;/code&gt; to be a &lt;strong&gt;number&lt;/strong&gt; (e.g. &lt;code&gt;exclusiveMinimum: 0&lt;/code&gt;, with no separate &lt;code&gt;minimum&lt;/code&gt;), not a boolean flag. A boolean &lt;code&gt;exclusiveMinimum&lt;/code&gt; is structurally invalid there — depending on the validator, this either gets silently ignored (wrong behavior but not a failure) or trips the validator into a degenerate "can't satisfy this constraint" / fail-closed state, which matches your symptom exactly: &lt;em&gt;every&lt;/em&gt; call to &lt;code&gt;nearby&lt;/code&gt; fails validation with no detail, regardless of what &lt;code&gt;radius&lt;/code&gt; value you send.&lt;/p&gt;

&lt;p&gt;My top suspect, in order of confidence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;&lt;code&gt;radius&lt;/code&gt;'s &lt;code&gt;exclusiveMinimum: true&lt;/code&gt; + &lt;code&gt;minimum: 0&lt;/code&gt;&lt;/strong&gt; (draft-4/OpenAPI-3.0 boolean form) — the one schema quirk unique to &lt;code&gt;nearby&lt;/code&gt;'s input among the three endpoints, and a very plausible reason the gateway's validator chokes consistently.&lt;/li&gt;
&lt;li&gt;Lower-confidence secondary suspect: the &lt;code&gt;type&lt;/code&gt;/&lt;code&gt;officialNames&lt;/code&gt;/&lt;code&gt;translations&lt;/code&gt; nested objects use &lt;code&gt;"nullable": true&lt;/code&gt; sitting alongside &lt;code&gt;"type": "object"&lt;/code&gt; plus &lt;code&gt;allOf&lt;/code&gt; — also an OpenAPI 3.0-ism that a strict JSON Schema validator won't interpret as "allow null." But this pattern is identical across &lt;code&gt;nearby&lt;/code&gt;, &lt;code&gt;search&lt;/code&gt;, and &lt;code&gt;reverse&lt;/code&gt; output schemas, so it wouldn't explain why only &lt;code&gt;nearby&lt;/code&gt; fails — unless the other two endpoints simply haven't been exercised yet or happen not to hit a null in your test data.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Workaround to try first, cheaply:&lt;/strong&gt; rewrite &lt;code&gt;radius&lt;/code&gt; in the input schema to the modern numeric form. If that alone makes &lt;code&gt;nearby&lt;/code&gt; pass, it confirms the gateway's validator is draft 2019-09+/2020-12-only and doesn't back-translate OpenAPI 3.0 boolean exclusiveMinimum — which would also mean you should audit the OpenAPI source for other boolean-style &lt;code&gt;exclusiveMinimum&lt;/code&gt;/&lt;code&gt;exclusiveMaximum&lt;/code&gt; usages before they bite another endpoint.&lt;/p&gt;

&lt;p&gt;Want me to produce the corrected &lt;code&gt;input-schema.json&lt;/code&gt; (and the matching OpenAPI fix) for you to try?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Nailed it! Indeed, that was the issue. The fix worked, I sent my API for review, and I also notified the support team that they don't need to debug anything, because I found the root cause.&lt;/p&gt;

&lt;h3&gt;
  
  
  Verdict
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Hopeless without agent?&lt;/strong&gt; Yes - I tried, I failed.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Added value&lt;/strong&gt;: Very few people have the patience to compare every attribute by hand against multiple versions of JSON Schema spec, looking for the needle in the haystack. The agent can do this in minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Agent performance&lt;/strong&gt;: The very first response found the root cause.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lesson learned&lt;/strong&gt;: Making manual, random changes to the schemas without clues was not a good idea.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Lessons learned &amp;amp; summary
&lt;/h2&gt;

&lt;p&gt;AI agents are good at analyzing large amount of information in short time, looking for patterns and anomalies. This is essential in the debugging process. I turned the findings into a skill, so that I don't have to remember explaining restrictions every time I debug a production issue. And here's exactly what I learned:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The more the problem is a "needle in the haystack", the more the agent can outperform human.&lt;/li&gt;
&lt;li&gt;Provide clear information, which parts of the system work, and which do not. In both cases, this helped the agent to triage the issue to the right parts of the code much quicker than humans could do.&lt;/li&gt;
&lt;li&gt;Be clear about what we know, and what we don't know about the issue.&lt;/li&gt;
&lt;li&gt;If you don't want to give the access to a certain resource (e.g. production server) as a safety measure, say it explicitly and explain, how the agent can ask you for additional information or test something.&lt;/li&gt;
&lt;li&gt;Asking to back the explanations with sources helps.&lt;/li&gt;
&lt;li&gt;Engineering skills still matter to assess the responses, and when we need to make the final decision: which of the fixes to apply, especially if we deal with a production system?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope that you will find the two stories useful also for you!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Used AI model and harness&lt;/strong&gt;: Claude Sonnet 5.5 (medium), Claude Code &lt;/p&gt;

</description>
      <category>ai</category>
      <category>debugging</category>
      <category>api</category>
      <category>database</category>
    </item>
  </channel>
</rss>
