fix(review): drop whitespace-only RAG chunks and surface real embed errors - #5029
Merged
Merged
Conversation
…rrors ai_embed_http_400 fired 485 times over 2 weeks, still ongoing. Two fixes: 1. chunkFile only checked the WHOLE file was non-empty before splitting -- an individual slice from newlineChunks/chunkJsTs could land entirely inside a run of blank/whitespace-only lines and reach the embed API as an empty string, the most plausible cause of a 400 from Ollama's OpenAI-compatible /embeddings endpoint. Filter after chunking instead. 2. The embed error path threw only the bare status code, discarding the response body -- diagnosing this required SSHing into production and reasoning from first principles instead of just reading the error. Now captures a bounded response-body detail (best-effort, never masks the status on a body-read failure), matching what future occurrences (this fix or otherwise) will need to actually diagnose. Closes #4996
Contributor
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #5029 +/- ##
=======================================
Coverage 94.36% 94.36%
=======================================
Files 457 457
Lines 39236 39236
Branches 14313 14313
=======================================
Hits 37024 37024
Misses 1558 1558
Partials 654 654
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Contributor
|
Important 🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪🟪 🔍 Gittensory is reviewing…AI analysis is in progress. This comment will update when the review is complete. 🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed · 🟪 Reviewing |
This was referenced Jul 11, 2026
embedTexts: one oversized/malformed chunk fails the WHOLE embedding batch, not just that chunk
#5072
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ai_embed_http_400fired 485 times over 2 weeks, still ongoing at filing time.AI_EMBED_MODEL=bge-m3:latestis correctly configured and the model is genuinely pulled in Ollama — ruling out a config/model-availability mismatch.chunkFileonly validated that the WHOLE file was non-empty before splitting — an individual slice fromnewlineChunks/chunkJsTscan land entirely inside a run of blank/whitespace-only lines and reach the embed API as an effectively-empty string, the most plausible cause of a 400 from Ollama's OpenAI-compatible/embeddingsendpoint. Filtered after chunking (single centralized guard covering both chunkers), preserving each surviving chunk's originalchunkIndex/idrather than renumbering.ai_embed_http_400), discarding the response body entirely — diagnosing this required live production archaeology (SSH, cross-referencing box config) instead of just reading the error. Now captures a bounded (300 char) response-body detail, best-effort so a body-read failure never masks the original status.Scope
type(scope): short summaryConventional Commit format, for examplefix(api): restore profile access checks.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Closes #4996).Validation
git diff --checknpm run actionlintnpm run typechecknpm run test:coveragelocallynpm run test:workersnpm run build:mcpnpm run test:mcp-packnpm run ui:openapi:checknpm run ui:lintnpm run ui:typechecknpm run ui:buildnpm audit --audit-level=moderateIf any required check was skipped, explain why:
test:coverage(full unsharded): not run end-to-end — ran scopedvitest --coveragefortest/unit/rag.test.ts+test/unit/selfhost-ai.test.ts(244 tests) and confirmed via lcov that every changed line/branch is covered.test:workers/build:mcp/test:mcp-pack/ui:lint/ui:typecheck/ui:build: not run — this change touches onlysrc/review/rag.tsandsrc/selfhost/ai.ts; no Worker-pool, MCP, or UI surface changed.Safety
UI Evidencesection. (N/A.)Notes
Part of a batch of 13 bug fixes filed from a Sentry-issue triage this session (#4994–#5006). This is #3 by impact.