fix(flow/retriever/parent): validate ParentIDKey is non-empty in NewRetriever#999
Open
octo-patch wants to merge 1 commit into
Open
Conversation
…etriever When ParentIDKey is empty, Retrieve silently finds no parent IDs for any sub-document and always returns empty results. Return an explicit error from NewRetriever when ParentIDKey is not provided, consistent with the validation pattern used for the other required fields. Fixes cloudwego#952 Co-Authored-By: Octopus <liyuan851277048@icloud.com>
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.
Fixes #952
Problem
NewRetrieverinflow/retriever/parentvalidatesRetrieverandOrigDocGetterbut silently accepts an emptyParentIDKey. WhenParentIDKeyis empty,Retrievelooks upsubDoc.MetaData[""]for every sub-document — a key that is never populated — so the function silently returns empty results regardless of the actual retrieval output.This is the retriever-side companion to the indexer fix in #953.
Solution
Added a
config.ParentIDKey == ""validation check inNewRetriever, consistent with the existing field validation pattern.Testing
Added
TestNewRetrieverValidationcovering all three required-field error cases (nil Retriever, nil OrigDocGetter, empty ParentIDKey). ExistingTestParentRetrieverpasses unchanged.