Problem
The NewIndexer function in flow/indexer/parent/parent.go and the NewRetriever function in flow/retriever/parent/parent.go both fail to validate that Config.ParentIDKey is non-empty.
If a caller provides an empty ParentIDKey (either by omission or mistake), the code silently stores the parent document ID under the empty string key "" in each sub-document's metadata:
// flow/indexer/parent/parent.go – Store()
subDoc.MetaData[p.parentIDKey] = subDoc.ID // stores under "" when parentIDKey is empty
The retriever then attempts to look up the parent ID using the same empty key:
// flow/retriever/parent/parent.go – Retrieve()
if k, ok := subDoc.MetaData[p.parentIDKey]; ok {
This silently produces wrong behaviour: the metadata entry ends up filed under "" rather than a meaningful key, so the parent-child relationship is essentially lost for any caller that inspects metadata with a real key name.
The existing NewIndexer already validates the three other required fields (Indexer, Transformer, SubIDGenerator), but the equally critical ParentIDKey is left unchecked.
Steps to Reproduce
// No error is returned – ParentIDKey silently defaults to ""
idx, err := parent.NewIndexer(ctx, &parent.Config{
Indexer: myIndexer,
Transformer: mySplitter,
SubIDGenerator: myGenerator,
// ParentIDKey intentionally omitted
})
// err == nil, but all sub-documents will have metadata[""]=parentID
Expected Behavior
NewIndexer and NewRetriever should return a descriptive error when ParentIDKey is empty, consistent with how the other required fields are validated.
Fix
Add a validation guard in both constructors:
// flow/indexer/parent/parent.go
if config.ParentIDKey == "" {
return nil, fmt.Errorf("parentIDKey is empty")
}
// flow/retriever/parent/parent.go
if config.ParentIDKey == "" {
return nil, fmt.Errorf("parentIDKey is empty")
}
Problem
The
NewIndexerfunction inflow/indexer/parent/parent.goand theNewRetrieverfunction inflow/retriever/parent/parent.goboth fail to validate thatConfig.ParentIDKeyis non-empty.If a caller provides an empty
ParentIDKey(either by omission or mistake), the code silently stores the parent document ID under the empty string key""in each sub-document's metadata:The retriever then attempts to look up the parent ID using the same empty key:
This silently produces wrong behaviour: the metadata entry ends up filed under
""rather than a meaningful key, so the parent-child relationship is essentially lost for any caller that inspects metadata with a real key name.The existing
NewIndexeralready validates the three other required fields (Indexer,Transformer,SubIDGenerator), but the equally criticalParentIDKeyis left unchecked.Steps to Reproduce
Expected Behavior
NewIndexerandNewRetrievershould return a descriptive error whenParentIDKeyis empty, consistent with how the other required fields are validated.Fix
Add a validation guard in both constructors: