fix(report): stop listing reports via PostgREST JSON paths (BUG-574)

Staging PostgREST rejects the executiveSummary JSON-path alias, so GET /api/reports 500s. Persist a plain card_summary column from the Markdown excerpt instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-07 11:08:00 +08:00
co-authored by Cursor
parent ad9283d1bd
commit b466a6fc8c
15 changed files with 517 additions and 10 deletions
+16
View File
@@ -8838,4 +8838,20 @@
- 复发自:unknown-time `block_scan``814c924e`)按时段长度偏置
- 修复版本:`517df002`
## BUG-574 | 报告列表 JSON 路径 select 在 staging PostgREST 上 500
- 状态:resolved
- 首次发现:2026-09-07
- 最近更新:2026-09-07
- 影响面:`GET /api/reports``personal_reports` 列表查询、报告中心卡片
- 用户现象:登录后报告中心无法打开列表,接口稳定返回 500 `{"error":"报告列表暂时无法读取","code":"report_generation_failed"}`。同一会话读取已有报告详情 200。
- 触发条件:部署含 `cfcd369d` 的应用后打开报告中心。自托管 PostgREST 解析 `card_summary:report_document->executiveSummary->>summary` 失败。
- 根因:列表 `select` 增加了 PostgREST JSON 路径别名。该语法未被 `test:db` 或真实 PostgREST 覆盖;supabase-js 返回的 PostgrestError 不是 `Error` 实例,列表日志只记 `UnknownError`
- 修复:列表改为普通列 `card_summary`;迁移增加可空 `text` 列(≤500 字符);`complete_personal_report_job` 从封面文档 `executiveSummary.summary`(MD「摘要」截取)写入。旧行不回填。列表 catch 记录 `code`/`hint`,不记行数据。
- 验证:`frontend/tests/database-personal-report-card-summary.test.ts`(可空、authenticated 只读、service_role 可写、超长拒绝、complete RPC 写入);列表/观测单测;部署后需按 `docs/operations/personal-report-staging.md` 用真实会话跑列表 GET + 详情 GET + 创建 POST。
- 防复发:新增 PostgREST JSON 路径、嵌套 embed 或别名必须有 `test:db` 真查询或部署后 smoke;禁止再用未经验证的 JSON 路径变体赌列表查询。
- 相关记录:无
- 复发自:无
- 修复版本:待提交(`codex/report-list-500-20260907`