Files
awoooi/apps/api/src/services
OG T c0f3509d39
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 2m0s
fix(drift-card): Drift Diff HTTP 400 — item-by-item 累計長度避免切斷 HTML
統帥回報 14:18 點 [查看 Diff] 收到 'Drift Diff 查詢失敗: HTTP error: 400'

真因 (telegram_gateway.py:2087 _send_drift_diff_detail):
  - report_id=7ffe78ae 有 48 items,單筆 git_value 最長 1794 字 (env array)
  - 累計 _full 遠超 4096,執行 _full[:3950] 截斷
  - 截斷可能切在 HTML tag 中間 (<code>... 或 &lt; entity 中間)
  - Telegram parse_mode='HTML' 拒絕不完整 HTML → 400

修復:
  - item-by-item 累計長度,單個 item 算 _block 長度+1
  - 預留 3800 上限 (4096 - 250 buffer 給 header + '… 還有 X 項' 提示)
  - 確保 _full 永遠是完整 HTML 結構

驗證: 下次 drift report 出現 + 統帥點 [查看 Diff] 應正常顯示 (本 session 的下個 cycle)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 14:26:29 +08:00
..