Will It Vibe logoWill It Vibe?
DJANGO-017Low severity-4 points

Bare except swallows a missing-object lookup

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 4 points from that category, once per scan, no matter how many places it turns up.

What it detects

A try block calls Model.objects.get(...) and the matching except (DoesNotExist or a bare/broad Exception) does nothing but pass or continue, discarding the not-found case silently instead of returning a 404 or a clear error. Django's own get_object_or_404() shortcut exists for exactly this and raises Http404 the caller can rely on.

Why it matters

A try/except around Model.objects.get() whose except clause (DoesNotExist or a bare/broad Exception) does nothing but pass or continue silently discards the not-found case. The caller has no idea the record was missing, which can mean skipping a step of business logic, showing a blank or broken page instead of a proper 404, or worse, silently proceeding with a None-like state further down the function.

How to fix it

Replace the manual try/except with get_object_or_404(Model, ...) in a view, which raises Http404 and lets Django render its standard 404 response. Outside a view (a background task, a management command), keep the try/except but do something meaningful in the except block: log it, return a clear error, or re-raise, instead of silently passing.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks