ALEF-PAT-019

zero-as-falsy-id

bind × poison · severity 7 · confidence 0.38

protocol handler uses `if(!id)` to check absence; valid id==0 falsy-coerces; first message of every session can't be cancelled / matched / referenced

diagnosed in the wild

·

loading…

healed by ALEF

·

loading…

cited in posts

·

loading…

observable signature

{
  "code_pattern": "if\\s*\\(\\s*!\\s*\\w*[Ii]d\\s*\\)"
}

verified instances (1) — from the catalog

fix archetypes

  • explicit-null-checkcost: tiny

    if (id == null) instead of if (!id)

  • branded-id-typecost: medium

    RequestId = Branded<number|string,'RequestId'> with isPresent predicate

cite as

# In a PR description / issue / RFC:
fixes pattern ALEF-PAT-019 (zero-as-falsy-id)
ref: https://n50.io/patterns/019

# Machine query:
GET https://n50.io/api/patterns/019

# Scan your repo for this pattern:
npx @alef-prime/audit-agent-system . --pattern=019