Repository navigation
fix(graphile-llm): treat blank VectorNearbyInput text as not given - #1970
Open
theothersideofgod wants to merge 2 commits into
Open
theothersideofgod wants to merge 2 commits into
theothersideofgod wants to merge 2 commits into
Conversation
A blank `text` is embedded today. A provider that returns no vector for it drops the vector filter under `degrade`, so the query returns the whole table without an error. These tests pin the intended behavior: blank text alone fails like neither field, and blank text beside a vector is ignored. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The `nearby` rule counted any string as text and embedded it. Ollama's nomic-embed-text answers `""` with no vector, and under the default `onQuotaExceeded: 'degrade'` the vector filter was then dropped, so `text: ""` returned every row with a null distance and no error. Blank text now counts as absent, the way the `unified` rule already treats a blank `unifiedSearch`. Blank text alone raises the "neither was given" error. Blank text beside a vector is ignored, the same way an empty vector beside text is ignored. The field description says so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Review complete. No issues found — approved ✅. The change aligns embed-input validation semantics for whitespace-only Reviewed commit: e7239cf |
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.
Why
VectorNearbyInputtakes exactly one ofvectorortext(#1955). Thenearbyrule inembed-inputs.tscounted any string as "text given", sotext: ""ortext: " "on its own was sent to the embedder instead of being rejected. What the client got then depended on the provider:nomic-embed-textanswers""with no vector, the defaultonQuotaExceeded: degradereturns without settingvector, and the filter disappears: the whole table comes back withnulldistances and no error.The
unifiedrule in the same file already treats blank text as not given (text.trim().length === 0).Change
In the
nearbyrule, text counts as given only when it is a string with non-whitespace content. Blank text on its own now raises the existing error, before any embedding call:VectorNearbyInput: provide exactly one of `vector` or `text`; neither was given.The "both" check still uses "a string was sent", so
vectorplus blanktextis still rejected as both. Thetextfield description and the plugin header say that blank text counts as not given.Not changed: the
{column}Textcompanion rule (an empty embed already fails there withEMBED_FAILED) and thedegradefallback when the provider fails on real text.Behavior changes
text: ""or whitespace alone, embedder configured. Was: embedded; with Ollama,""dropped the filter (whole table,nulldistances) and whitespace ranked by an unrelated vector. Now:neither was givenerror; the embedder is not called. Why: blank text is not a query, and returning the unfiltered table without an error is a wrong result.textalone, no embedder configured. Was:VectorNearbyInput: `text` needs an embedding provider and none is configured; send `vector` instead.Now:neither was given. Why: the input is checked before the provider (read from the code; no test covers this case).vectorplus blanktext: unchanged,not both(covered by a new test).Question for the owner
Should
vectorplus blanktextbe accepted as a vector query? This PR keeps it an error, as #1955 defined.Before / after
Base: origin/main
f1f197863.cd graphile/graphile-llm && PGPORT=15432 pnpm exec jest src/__tests__/embed-inputs.test.tsTests: 2 failed, 26 passed, 28 total. Bothrejects a VectorNearbyInput whose only input is blank text ""and... " "fail atexpect(result.errors?.[0]?.message).toMatch(...)(embed-inputs.test.ts:265) withReceived has value: undefined: no error, the query ran.Tests: 28 passed, 28 total. Whole package:98 passedon the base,101 passedwith this PR (3 new tests).tsc --noEmitandeslint .exit 0 (2 existing warnings, in files this PR does not touch).Cluster end-to-end
A GraphQL image built from the deployed pin (
ca40d826b) plus this fix (same patch-id) and the #1955 commits it depends on, swapped into a local cluster and swapped back afterwards. Query:dataRoomFileswithembeddingVectorDistanceandVectorNearbyInput { text }, as a tenant user.text: ""nullprovide exactly one of `vector` or `text`; neither was given.,dataRoomFiles: nullnulltext: " "neither was giventext: "when did the lava…"(sanity)Row counts grow 6 → 8 → 10 because each run added two files. The deployed image also returned
Float cannot represent non numeric value: Infinityerrors on rows without embeddings in the" "and sanity queries; that is a separate chunk-distance bug (not part of this PR), and those errors are gone in the "after" column only because that test image also carried a fix for it. The cluster image runs an older pin than main, and the gateway route from #1961 was not part of it; what the gateway returns for""was not tested. The fix rejects blank text before any embedding call, so it does not depend on the provider's answer.Rules touched: none (graphile-llm input validation only).
🤖 Generated with Claude Code