Skip to content

False positive: missing_error_handling doesn't understand try/catch control flow #8

Description

@CodeDeficient

Problem

The missing_error_handling pattern flags fetch calls as "missing error handling" even when they ARE inside try/catch blocks. The tool only sees the fetch( line, not the surrounding control flow.

Example - code that IS correct but flagged:

try {
  const response = await fetch('/api/trucks/...', {...});
  if (!response.ok) {
    throw new Error(\`Failed: \${response.status}\`);
  }
} catch (error_) {
  logError('API error:', error_);
  throw error_;
}

Some affected locations in food-truck-finder-poc:

  • components/owner/PendingUpdatesQueue.tsx:116
  • components/map/TrafficVolumeLayer.tsx:136
  • app/owner-dashboard/_components/events/MyApplications.tsx:101
  • app/organizer/_components/VerificationStatus.tsx:77
  • app/admin/_components/AdminDashboardClient.tsx:36

Root Cause

The pattern matcher only looks for fetch( token sequence without analyzing:

  1. Whether it's inside a try block
  2. Whether the function has error handling elsewhere

Severity

Medium - Causes significant noise in reports, undermines trust in the tool.

Suggested Fix

Either:

  1. Make the pattern aware of try/catch control flow
  2. Rename to "uncaught_fetch" for fetch calls not in any error-handling scope

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions