Skip to content

no-folded-bad-request-not-found

Do not handle HTTP 400 and 404 statuses in one branch.

Why

A 400 means the request or its configuration is wrong; folding it into the not-found path makes a misconfiguration log success with an empty result, indistinguishable from a deleted record.

Fix

Give 404 its own branch and raise the 400 as a non-retriable client error.

Examples

Before — flagged A 400 is treated as not found
client/records.py
def fetch(response):
if response.status_code in (400, 404):
return None
return response.json()
After — preferred Not found and bad request are separate outcomes
client/records.py
def fetch(response):
if response.status_code == 404:
return None
if response.status_code == 400:
raise ValueError(response.text)
return response.json()