From 36e464f66881f0d82ee47657635f8a450be79ab0 Mon Sep 17 00:00:00 2001 From: Chaim Date: Sun, 3 May 2026 19:04:46 +0000 Subject: [PATCH] fix(halachot): exclude embedding from update_halacha RETURNING MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PATCH /api/halachot/{id} was returning 500 because the row included ``embedding`` as a numpy.ndarray of np.float32, which FastAPI's jsonable_encoder cannot serialize (vars() and dict() both fail on it). The bug had been latent — it triggered for the first time today after the auto-approve batch left only low-confidence halachot for the chair to review manually, and her first PATCH hit the unserializable response. Replace ``RETURNING *`` with an explicit column list (everything except ``embedding``). Callers that need the embedding can re-fetch via ``get_halacha`` — but no current caller does. Co-Authored-By: Claude Opus 4.7 (1M context) --- mcp-server/src/legal_mcp/services/db.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mcp-server/src/legal_mcp/services/db.py b/mcp-server/src/legal_mcp/services/db.py index 8e8ad1c..f4207b3 100644 --- a/mcp-server/src/legal_mcp/services/db.py +++ b/mcp-server/src/legal_mcp/services/db.py @@ -2096,7 +2096,17 @@ async def update_halacha( if not set_parts: return None set_parts.append("updated_at = now()") - sql = f"UPDATE halachot SET {', '.join(set_parts)} WHERE id = $1 RETURNING *" + # Exclude `embedding` — it's a numpy.ndarray of np.float32 that breaks + # FastAPI's jsonable_encoder downstream (PATCH /api/halachot/{id}). + # Callers that need it (none today) can re-fetch with get_halacha. + sql = f""" + UPDATE halachot SET {', '.join(set_parts)} WHERE id = $1 + RETURNING id, case_law_id, halacha_index, rule_statement, rule_type, + reasoning_summary, supporting_quote, page_reference, + practice_areas, subject_tags, cites, confidence, + quote_verified, review_status, reviewer, reviewed_at, + created_at, updated_at + """ row = await pool.fetchrow(sql, *params) return dict(row) if row else None