fix(halachot): exclude embedding from update_halacha RETURNING
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m26s
All checks were successful
Build & Deploy / build-and-deploy (push) Successful in 1m26s
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) <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user