<?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: Carlos Luque Zayas Bazan</title>
    <description>The latest articles on DEV Community by Carlos Luque Zayas Bazan (@carlos_luquezayasbazan_).</description>
    <link>https://dev.to/carlos_luquezayasbazan_</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%2F4209543%2Fcf4d8e98-ad29-402c-8a76-a6ed29cd3e49.png</url>
      <title>DEV Community: Carlos Luque Zayas Bazan</title>
      <link>https://dev.to/carlos_luquezayasbazan_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/carlos_luquezayasbazan_"/>
    <language>en</language>
    <item>
      <title>Why API Hallucinations Are Invisible to Your Linter (And How I Built a Parser to Catch Them.</title>
      <dc:creator>Carlos Luque Zayas Bazan</dc:creator>
      <pubDate>Mon, 26 Oct 2026 21:31:01 +0000</pubDate>
      <link>https://dev.to/carlos_luquezayasbazan_/why-api-hallucinations-are-invisible-to-your-linter-and-how-i-built-a-parser-to-catch-them-1185</link>
      <guid>https://dev.to/carlos_luquezayasbazan_/why-api-hallucinations-are-invisible-to-your-linter-and-how-i-built-a-parser-to-catch-them-1185</guid>
      <description>&lt;p&gt;When an AI coding assistant writes requests.get_json() instead of response.json(), the code compiles. Tests pass. Type checkers don't complain. SAST tools don't flag it. And yet the method doesn't exist.&lt;br&gt;
This is an API hallucination. It's a specific failure mode of AI-generated code that most static analysis tools miss because they're looking for known vulnerabilities or suspicious patterns, not for calls to functions that were never real to begin with.&lt;br&gt;
I've been building a CLI in Go that parses Python code and checks whether the functions and methods it calls actually exist in the library. The core idea is simple: if you know the valid API surface of requests, json, and os, you can flag requests.get_json() because get_json isn't in that surface.&lt;br&gt;
The parsing is done with gotreesitter, a pure-Go implementation of tree-sitter. I chose it over the CGO binding because I needed to compile on Windows without MinGW. The tradeoff is performance (the pure-Go version is slower), but for a CLI that analyzes individual files, the difference is milliseconds.&lt;br&gt;
The hard part isn't the parser. It's the registry of valid APIs. For the first version, I hardcoded the valid methods for three libraries. That's enough to demonstrate the concept, but it doesn't scale. Expanding it to pandas, numpy, or django requires either manual curation or extracting method names from type stubs.&lt;br&gt;
What I've learned so far: API hallucinations are predictable. They follow patterns — plausible-sounding method names, slight variations on real APIs, invented functions that "should" exist. A deterministic checker can catch them if it knows what's real. The question is how to build that "what's real" database without drowning in maintenance.&lt;br&gt;
The code isn't public yet, but I'm sharing the approach because I think the problem is worth solving. If you've seen API hallucinations in your own AI-generated code, I'd like to hear how you catch them.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>api</category>
      <category>cli</category>
      <category>python</category>
    </item>
  </channel>
</rss>
