Skip to main content
ai-slop/hidden-fallbackmanual fix

Hidden fallback.

A safe-looking default (`0`, `[]`, `{ ok: true }`) standing in for missing input or a failed call. A loud error becomes a quiet wrong answer.

Flagged shape and clean shape.

Each example shows the exact code shape the rule is looking for, then the smallest version that keeps the intent without hiding risk or adding noise.

hidden-fallback.ts
✗ Flagged
export async function chargeCustomer(order: Order) {
  try {
    return await payments.charge(order.total, order.customerId)
  } catch {
    return { ok: true }
  }
}
Why this trips

Deterministic AST match on JS/TS: flags `||`/`??` defaults and `Math.max`/`Math.min` clamps applied to failure-state values when nearby text mentions a fallback, missing, failed, or impossible state, and catch blocks that return a safe default or success-shaped object without surfacing the error.

hidden-fallback.ts
✓ Clean
export async function chargeCustomer(order: Order): Promise<ChargeResult> {
  try {
    const receipt = await payments.charge(order.total, order.customerId)
    return { ok: true, receipt }
  } catch (error) {
    return { ok: false, error }
  }
}
What changed

Handle the missing input explicitly: require the value, return a typed error, or name the conservative estimate so callers know it is not authoritative.

Agents prefer code that never throws, so they cover missing or failed state with a value the caller cannot tell apart from a real result.

How this rule is justified.

Rule id

ai-slop/hidden-fallback

Enforcing engine

ai-slop

Detector strategy

Deterministic AST match on JS/TS: flags `||`/`??` defaults and `Math.max`/`Math.min` clamps applied to failure-state values when nearby text mentions a fallback, missing, failed, or impossible state, and catch blocks that return a safe default or success-shaped object without surfacing the error.

Legitimate code that is NOT flagged

`process.env` defaults, string defaults that are not status words, catch blocks that log, throw, or return the caught error, and non-production paths are not flagged.

Evidence

Introduced in aislop v0.13.0 for JS/TS and calibrated in v0.13.1.