fix(translate): add EXPLORE logging for LLM JSON parse failures
Preview + executor now log the raw LLM response (first 1000 chars) when JSON parsing fails, enabling debugging of malformed LLM output. Previously ValueErrors from JSON parse failures were silently returned as 400 without any diagnostic data in logs.
This commit is contained in:
@@ -999,8 +999,10 @@ class TranslationExecutor:
|
||||
try:
|
||||
data = json.loads(match.group(1))
|
||||
except json.JSONDecodeError:
|
||||
logger.explore("LLM response was not valid JSON (after markdown extraction)", extra={"src": "executor", "response_preview": response_text[:1000]})
|
||||
raise ValueError("LLM response was not valid JSON")
|
||||
else:
|
||||
logger.explore("LLM response was not valid JSON (no markdown block)", extra={"src": "executor", "response_preview": response_text[:1000]})
|
||||
raise ValueError("LLM response was not valid JSON")
|
||||
|
||||
rows = data.get("rows", [])
|
||||
|
||||
@@ -1005,8 +1005,10 @@ class TranslationPreview:
|
||||
try:
|
||||
data = json.loads(match.group(1))
|
||||
except json.JSONDecodeError:
|
||||
logger.explore("LLM response was not valid JSON (after markdown extraction)", extra={"src": "preview", "response_preview": response_text[:1000]})
|
||||
raise ValueError("LLM response was not valid JSON")
|
||||
else:
|
||||
logger.explore("LLM response was not valid JSON (no markdown block)", extra={"src": "preview", "response_preview": response_text[:1000]})
|
||||
raise ValueError("LLM response was not valid JSON")
|
||||
|
||||
rows = data.get("rows", [])
|
||||
|
||||
Reference in New Issue
Block a user