From 5c7e5c663ea5bca559795493030a8f8b17d9615a Mon Sep 17 00:00:00 2001 From: Ty Balascio Date: Fri, 25 Sep 2026 12:04:53 -0700 Subject: [PATCH] fix(backend): log create_slab driver errors server-side QUALITY-120 keeps the driver stack out of the owner-facing response, but the bare except logged nothing, so a failing create was undiagnosable in the field. Log the exception server-side while keeping the generic owner message. --- backend/slabs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backend/slabs.py b/backend/slabs.py index 8a121b6..b52112d 100644 --- a/backend/slabs.py +++ b/backend/slabs.py @@ -6,6 +6,7 @@ sets deleted_at; published slabs cannot be deleted. """ import json +import logging from datetime import datetime, timezone from typing import Any, Dict, List @@ -15,6 +16,8 @@ from fastapi.responses import JSONResponse, Response from .db import get_connection from .thickness_band import load_thickness_terms, resolve_thickness_band_id +logger = logging.getLogger("slab.backend") + router = APIRouter(prefix="/api/v1/slabs") # Client-settable slab columns (explicit allowlist; never build SQL from client keys). @@ -224,8 +227,10 @@ async def create_slab(payload: Dict[str, Any]) -> Dict[str, Any]: try: conn.execute(f"INSERT INTO slabs ({', '.join(cols)}) VALUES ({ph})", vals) conn.commit() - except Exception: - # QUALITY-120: never surface a driver stack to the owner. + except Exception as exc: + # QUALITY-120: never surface a driver stack to the owner, but log it + # server-side so a failing create is diagnosable. + logger.error("create_slab insert failed: %s", exc, exc_info=True) return _err("validation", "Could not create the slab. Check the fields and try again.", status=400) row = conn.execute("SELECT * FROM slabs WHERE id=?", (payload["id"],)).fetchone() return _row_to_slab(row)