From 90ae0ac38eb406779e9db7153c1eec2a179fe544 Mon Sep 17 00:00:00 2001 From: Claude Lin & Lay Date: Mon, 27 Apr 2026 18:54:19 +0900 Subject: [PATCH] chore(fts): enrich D1 upsert failure logs to surface root cause (#135) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit processAndUpsertCommitDiff の FTS5 upsert 失敗ログに、根本原因特定に必要な 構造化詳細を追加する。既存の "Failed to upsert FTS5 row for diff ..." 行は ログ検索性のため温存し、新たに `FTS5 diff upsert detail (#135):` 行で errorName / vectorId / tokenizerKind / contentChars / filePathChars / fileStatus / commitSha / repo を JSON として出力する。 #135 の現状ログは ftsErr.message のみで D1 側の具体エラー型・該当行サイズが 見えず、cross-repo / diff-only という発生パターンから先に進めない。本変更は 観測フェーズの最小一手で、次回 :30 cron 実行で構造化ログが残れば、後続 PR で根本原因対応 (trigram tokenizer 限界 / content size / 特殊バイト等の仮説) に進める。 Refs #135 --- src/pipeline.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pipeline.ts b/src/pipeline.ts index a996f31..7c08ab8 100644 --- a/src/pipeline.ts +++ b/src/pipeline.ts @@ -1183,10 +1183,26 @@ export async function processAndUpsertCommitDiff( content: inputs[i], }); } catch (ftsErr) { + // Keep the high-level line for log searchability, then surface the underlying + // D1 error shape on a second line so the next cron run produces actionable + // context (error name, vector_id, content/path sizes). See #135. console.error( `Failed to upsert FTS5 row for diff ${repo}@${commitSha}/${f.filename}:`, ftsErr instanceof Error ? ftsErr.message : String(ftsErr), ); + console.error( + `FTS5 diff upsert detail (#135):`, + JSON.stringify({ + errorName: ftsErr instanceof Error ? ftsErr.name : typeof ftsErr, + vectorId: v.id, + tokenizerKind: "code", + contentChars: inputs[i].length, + filePathChars: f.filename.length, + fileStatus: normaliseFileStatus(f.status), + commitSha, + repo, + }), + ); } }