fix(analysis): log exceptions on analysis failure — was silently swallowed

This commit is contained in:
Macky
2026-10-01 20:56:16 +07:00
parent df0428d7d2
commit a7abc724be

View File

@@ -737,6 +737,7 @@ def _run_analysis(app, gid: str, inp: dict, persona_channel: str, llm) -> None:
channel=inp.get("channel", "social"),
)
except Exception:
app.logger.exception("analysis failed for group %s (sales kit)", gid)
s["groups"].update(gid, status="failed", error="analysis_failed")
return
try:
@@ -752,6 +753,7 @@ def _run_analysis(app, gid: str, inp: dict, persona_channel: str, llm) -> None:
raise ValueError("persona generation returned malformed personas")
personas = [persona for persona in personas if persona is not None]
except Exception:
app.logger.exception("analysis failed for group %s (persona generation)", gid)
s["groups"].update(gid, status="failed", error="analysis_failed")
return
@@ -765,6 +767,7 @@ def _run_analysis(app, gid: str, inp: dict, persona_channel: str, llm) -> None:
try:
report = build_report(sales_kit=sales_kit, personas=personas, language=inp.get("language", "th"))
except Exception:
app.logger.exception("analysis failed for group %s (report)", gid)
s["groups"].update(gid, status="failed", error="analysis_failed")
return
# Publish the completed analysis as one atomic record replacement. Readers
@@ -778,6 +781,7 @@ def _run_analysis(app, gid: str, inp: dict, persona_channel: str, llm) -> None:
report=report,
)
except (TypeError, ValueError):
app.logger.exception("analysis failed for group %s (publish)", gid)
s["groups"].update(gid, status="failed", error="analysis_failed")