Skip to main content

SKY-L012 · AI-code defects

Phantom symbol reference

Critical

The catalog gives no severity for this rule; every detector behind it reports CRITICAL.

A phantom symbol is a function, class or name that the code uses but that does not exist where the code says it lives: auth.verify_token() when the project's auth module only defines verify_access_token. SKY-L012 checks each reference into the project's own modules, and into a few installed packages, against what those modules really define.

Languages
Python, Go, Java, TypeScript, JavaScript
Turned on by
skylos . --ai-defects (or -a); reads the code as it is, no diff needed
Quality gate
counted toward the gate limits; a CRITICAL finding fails the gate on its own (full and diff scans). Counts toward max_ai_defects. Every finding is CRITICAL, and block_ai_defect_severities (under [tool.skylos.gate]) is ["CRITICAL"] by default, so one finding fails the gate on its own. The agent hook (skylos verify) also blocks on it.
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Coding agents guess helper names that sound right. In Python the guess fails only when that line runs, often on the error path or in the security check nobody exercised, and a missing verify_token can crash the endpoint it was meant to protect. In Go, Java and TypeScript the build breaks, but only after the change has been written and reviewed.

What Skylos flags

app/__init__.py · Python
 
app/auth.py · Python
"""Token checks for the API.""" import hashlibimport hmac  def verify_access_token(token, secret):    body, _, signature = token.rpartition(".")    expected = hmac.new(secret, body.encode(), hashlib.sha256).hexdigest()    return hmac.compare_digest(expected, signature)
app/views.py · PythonReported on line 5
from app import auth  def get_invoice(request, invoice_id, secret):    if not auth.verify_token(request.headers["Authorization"], secret):        return {"status": 401}    return {"status": 200, "invoice": invoice_id}

What Skylos leaves alone

app/__init__.py: same as in the flagged example.

app/auth.py: same as in the flagged example.

app/views.py · Python
from app import auth  def get_invoice(request, invoice_id, secret):    header = request.headers["Authorization"]    if not auth.verify_access_token(header, secret):        return {"status": 401}    return {"status": 200, "invoice": invoice_id}

Why Skylos leaves it alone

The view calls the helper that app/auth.py really defines. Skylos resolves auth to the local module, finds verify_access_token among its top-level names and has nothing to report.

More languages

Go

Flagged

go.mod · Text
module example.com/shop go 1.22
auth/token.go · Go
package auth import "strings" func VerifyAccessToken(header string) bool {	return strings.HasPrefix(header, "Bearer ") && len(header) > 7}
api/invoices.go · GoReported on line 10
package api import (	"net/http" 	"example.com/shop/auth") func GetInvoice(w http.ResponseWriter, r *http.Request) {	if !auth.VerifyToken(r.Header.Get("Authorization")) {		w.WriteHeader(http.StatusUnauthorized)		return	}	w.WriteHeader(http.StatusOK)}

Not flagged

go.mod: same as in the flagged example.

auth/token.go: same as in the flagged example.

api/invoices.go · Go
package api import (	"net/http" 	"example.com/shop/auth") func GetInvoice(w http.ResponseWriter, r *http.Request) {	if !auth.VerifyAccessToken(r.Header.Get("Authorization")) {		w.WriteHeader(http.StatusUnauthorized)		return	}	w.WriteHeader(http.StatusOK)}

Why Skylos leaves it alone

example.com/shop/auth is a package of this module (go.mod), and it exports VerifyAccessToken. The flagged version names VerifyToken, which the package does not declare; the finding lists the close match.

TypeScript

Flagged

src/auth/token.ts · TypeScript
export function verifyAccessToken(header: string): boolean {  return header.startsWith("Bearer ") && header.length > 7;}
src/routes/invoices.ts · TypeScriptReported on line 1
import { verifyToken } from "../auth/token"; export function getInvoice(headers: Record<string, string>, id: string) {  if (!verifyToken(headers["authorization"])) {    return { status: 401 };  }  return { status: 200, id };}

Not flagged

src/auth/token.ts: same as in the flagged example.

src/routes/invoices.ts · TypeScript
import { verifyAccessToken } from "../auth/token"; export function getInvoice(headers: Record<string, string>, id: string) {  if (!verifyAccessToken(headers["authorization"])) {    return { status: 401 };  }  return { status: 200, id };}

Why Skylos leaves it alone

The import names an export that src/auth/token.ts really has. In TypeScript and JavaScript the finding sits on the import line, where the missing name is first requested.

How Skylos decides

  1. Python: builds a table of every module in the project and the names each one defines at top level, imports or re-exports. It then follows each from app.auth import name, auth.name(...), auth.name and @auth.name in the scanned files to the local module it points at, and reports the reference when that module has no such name. Decorators are reported as SKY-L023 instead.
  2. Python, stays silent when the name may exist: the target module has a module-level __getattr__ or otherwise writes its own namespace, the name is bound only in some branches, the reference sits under a try/except AttributeError (or ImportError for imports), or it is only used for type checking and the module defines it there.
  3. Python, bare calls: a call to a name that is not bound anywhere in scope is reported when it closely resembles a function elsewhere in the project (a stale name after a rename). A separate check reports a bare call to a well-known security helper name, such as sanitize_input() or verify_token(), that the file neither defines nor imports.
  4. Python, installed packages: for the packages the API signature check inspects (requests, pandas, boto3, openai, jwt, or api_signature_modules), an import of a submodule that the installed package does not have, such as from requests.retry import Retry, is reported under this rule too.
  5. Go: resolves imports of packages in the same module (from go.mod) and reports pkg.Name when that package does not declare an exported Name. Java: checks references to the project's own classes and static members. TypeScript and JavaScript: checks named imports from relative project files against what those files export. Each finding lists close matches when there are any.

How to fix it

Call the helper that really exists, or write the missing one in the module the code imports it from. Do not silence the finding by catching the resulting AttributeError: the check would still never run.

app/views.py · Python · the fix, against the flagged file
from app import auth  def get_invoice(request, invoice_id, secret):Removed:     if not auth.verify_token(request.headers["Authorization"], secret):Added:     header = request.headers["Authorization"]Added:     if not auth.verify_access_token(header, secret):        return {"status": 401}    return {"status": 200, "invoice": invoice_id}

When it can be wrong

  • A module that adds names at run time in a way Skylos cannot follow, for example a plugin loader that calls setattr() on another module with a computed name, can make a real name look missing.
  • A bare call to a security-helper name such as sanitize_input() is reported when the name comes from a star import of an installed package or a builtins patch, because the file neither defines nor imports it by name.
  • To add your own helper names to the security list, set extra_phantom_names under [tool.skylos.vibe].

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • On the reported line, with the reason the name exists at run time:

    Python
    if not auth.verify_token(header, secret):  # skylos: ignore[SKY-L012] plugin adds it
  • [tool.skylos] ignore = ["SKY-L012"] turns the rule off for the project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.