fix(tradein/security): admin.py — generic detail + error-id вместо сырого текста исключений (#2234) #2261

Merged
lekss361 merged 2 commits from fix/tradein-admin-exception-leak into main 2026-07-03 06:27:23 +00:00
Showing only changes of commit efa0bafa18 - Show all commits

View file

@ -688,8 +688,13 @@ async def scrape_avito_imv(
has_loggia=has_loggia,
)
except IMVAddressNotFoundError as e:
raise _safe_http_error(
404, "IMV address not found", f"avito-imv: address not found for {address}"
# Ожидаемое клиентское условие (адрес не в базе Avito), НЕ сбой — logger.warning
# без traceback, чтобы не шуметь exception-событиями в GlitchTip. Адрес — в лог,
# не в HTTP-ответ.
error_id = uuid4().hex[:8]
logger.warning("avito-imv: address not found for %s (error-id=%s)", address, error_id)
raise HTTPException(
status_code=404, detail=f"IMV address not found (error-id: {error_id})"
) from e
except Exception as e:
raise _safe_http_error(502, "fetch failed", f"avito-imv: fetch failed for {address}") from e