Repository navigation
fix(python): skip OpenAI embedding requests when no valid text remains - #5195
Merged
Merged
Conversation
Co-authored-by: saudademjj <[email protected]>
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
There was a problem hiding this comment.
✅ Gate recommendation: approve.
Returning immediately after filtering avoids SDK initialization and empty requests while preserving one result per input. The regression tests cover empty and all-filtered batches, plus Embedded ingestion that retains both rows with null vectors.
BubbleCal
approved these changes
Nov 24, 2026
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
Follows up on #4005, which handled mixed batches in
OpenAIEmbeddings.generate_embeddings. Onmain, when the input batch is empty ([]) or filtering leaves no valid texts (such as[None, ""]),generate_embeddingsstill imports theopenaiSDK and callsembeddings.create(input=[], ...).[None] * len(texts)early inpython/python/lancedb/embeddings/openai.pywhen no valid texts remain ([]for empty input, oneNoneper item when all inputs are filtered), before importing theopenaiSDK or sending a request.python/python/tests/test_embeddings.pycovering empty batches, all-filtered batches, and native-backedtable.add(..., on_bad_vectors="null")verifying rows are kept with null vectors and no OpenAI request is made.Attribution
Successor to #3152. The early return and nullable ingestion test were originally contributed by @saudademjj in #3152.
Verification
embeddings.create(input=[], ...)) and passed after.148 passed, 1 skipped, 9 deselected(mocked client only; no live OpenAI API calls).python/tree (scoped topython/only).Co-authored-by: saudademjj [email protected]