Skip to content

fix(pipeline): hash vector IDs to stay under Vectorize 64 byte cap - #84

Merged
liplus-lin-lay merged 1 commit into
mainfrom
83-bugpipeline-vectorize-vector-id-exceeds-64-byte-limit-for-long-paths-and-commit-diffs
Apr 19, 2026
Merged

fix(pipeline): hash vector IDs to stay under Vectorize 64 byte cap#84
liplus-lin-lay merged 1 commit into
mainfrom
83-bugpipeline-vectorize-vector-id-exceeds-64-byte-limit-for-long-paths-and-commit-diffs

Conversation

@liplus-lin-lay

Copy link
Copy Markdown
Member

Refs #83

Vectorize の Vector ID 64 byte 上限を超えて VECTOR_UPSERT_ERROR (code=40008) で embed が失敗する問題を修正する。doc 長パス (74 byte) と、PR #81 で導入された diff ID scheme (100 byte 以上、原理的に動いていなかった) の両方が対象。

変更方針 (issue #83 Option A)

  • すべての vector surface の ID を {prefix}:{base64url(sha256(parts.join("\0")))} 形式に統一
  • prefix は surface 別 (i issue/pr, d doc, r release, c diff) の 1 文字 + : 区切り
  • 出力長は常に 46 byte (2 + 1 + 43) で、64 byte 上限に 18 byte 余裕
  • 同じ入力 → 同じ ID の deterministic hash。polling の change-detection には影響なし

変更ファイル

  • src/pipeline.tsstableVectorId 導入、4 surface の ID builder を async 化、processAndUpsertCommitDiff の chunk 内 ID 生成を Promise.all
  • src/webhook.tsdeleteByIds 呼出の await 追従 (issue/release/doc 3 箇所)
  • src/poller.ts — doc deletion の await 追従

src/mcp.ts は search_issues の URL builder が既に metadata (doc_path / file_path / commit_sha / number) ベースで組まれており、ID からの reverse-parse は無かったので変更なし。

既存 index 互換性

  • 本 PR では既存 vector を自動 cleanup しない
  • 新 push / 新 poll で新 ID の vector が upsert される → 新旧が Vectorize 内に共存 (古いは参照されなくなるが残る)
  • 完全 wipe が必要なら従来どおり /admin/reset-hashes 経由で再 embed

影響範囲と互換性

  • 破壊的変更なし (public API shape 不変、search_issues 結果の URL 構築は metadata ベースのまま)
  • TypeScript strict 通過、wrangler dry-run bundle 成功
  • docs/ の Vector ID scheme に関する具体記述は無かったため docs 変更なし

Vectorize enforces a 64-byte limit on vector IDs. The previous scheme
embedded repo + path/tag/sha as plain text and overflowed for long
paths and for commit-diff IDs (e.g. docs/b.-... 74 bytes, diff IDs
routinely >100 bytes), causing every affected embed to fail with
VECTOR_UPSERT_ERROR code 40008.

すべての vector surface (issue / pr / release / doc / diff) の ID を
SHA-256 digest を base64url で 43 char に収めたハッシュ方式に統一し、
type prefix 1 文字 + ":" を付けて常に 46 byte に揃える。同じ入力から
同じ ID が出るので polling の change-detection には影響しない。呼出元
は async 化に追従して await を追加。mcp.ts は既に metadata ベースで
URL を組んでいるため変更なし。既存 index の vector は古い ID のまま
残り、新 push / poll で新 ID が upsert される。完全 wipe が必要な場合
は従来どおり /admin/reset-hashes 経由で再 embed する。

Closes #83

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
github-rag-mcp 8fdb906 Apr 19 2026, 09:06 AM

@liplus-lin-lay
liplus-lin-lay merged commit 215e2e2 into main Apr 19, 2026
3 checks passed
@liplus-lin-lay
liplus-lin-lay deleted the 83-bugpipeline-vectorize-vector-id-exceeds-64-byte-limit-for-long-paths-and-commit-diffs branch April 19, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(pipeline): Vectorize vector ID exceeds 64 byte limit for long paths and commit diffs

1 participant