fix(knowledge): bound source titles and tag values so an oversized index row cannot fail a connector sync - #8123
Conversation
…dex row cannot fail a connector sync
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
…reject oversized filenames and tags at the document APIs
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…inside the limit and leave stored upload metadata untouched
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
…ong tag values on the tag-data and tag-update paths
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
filenameand text tag columns carry btree indexes, and Postgres refuses an index row past 2704 bytes (SQLSTATE 54000). Reproduced on the real schema: an incompressible 2,700-character filename fails withindex row size 2712 exceeds btree version 4 maximum 2704 for index "doc_filename_idx", a 3,200-character tag fails ondoc_kb_tag1_lower_idx, 2,600 characters insert. Connector syncs wrote source titles and mapped metadata straight into those columns, and the failure-recording path re-inserts the same title, so one such document escalates to a connector-level failure on every sync and ten of those disable the connectorMAX_DOCUMENT_INDEXED_TEXT_LENGTH(512 characters, under the ceiling even at four bytes per character) inlib/knowledge/constants.ts.max()onfilename(create, upsert, update) and ontag1..tag7(create, update), and the upload-metadata tag bound (previously 1000 characters, which still overflows at four bytes per character) now uses the same constantdoc_filename_idxitself looks close to unused in production (338 scans against millions on the tag indexes); dropping it is a separate, evidence-gated migrationType of Change
Testing
sync-persistence.test.ts: bounded filename on the placeholder path, bounded and intact mapped tag values, code-point cut on a 600-emoji titledocuments.test.ts: at-limit accepted; over-limit filename rejected on create/upsert/update and over-limit tag rejected on create/update, with the descriptive messagesupload-metadata.test.ts: over-limit tag rejectedbun run type-checkandbun run check:api-validationpass; the mechanism was reproduced on a local database with the real indexes inside rolled-back transactionsChecklist