fix(search): harden tag scope resolution after #1907

Default missing KB metadata to document tag relation lookup, propagate tag resolution failures instead of returning empty results, and reject ambiguous bare tag_ids when multiple knowledge bases are in scope.
This commit is contained in:
wizardchen
2026-07-06 23:38:43 +08:00
committed by lyingbug
parent 0db71bf2f8
commit d9bb7aa8f2
6 changed files with 142 additions and 22 deletions
+8
View File
@@ -44,3 +44,11 @@ func TestMergeTagScopesFromRequestIDs_AmbiguousKBIgnored(t *testing.T) {
scopes := mergeTagScopesFromRequestIDs(nil, []string{"tag-9"}, []string{"kb-1", "kb-2"})
assert.Empty(t, scopes)
}
func TestValidateUnscopedTagIDs(t *testing.T) {
assert.NoError(t, validateUnscopedTagIDs(nil, nil))
assert.NoError(t, validateUnscopedTagIDs(nil, []string{"kb-1", "kb-2"}))
assert.NoError(t, validateUnscopedTagIDs([]string{"tag-9"}, []string{"kb-1"}))
assert.Error(t, validateUnscopedTagIDs([]string{"tag-9"}, []string{"kb-1", "kb-2"}))
assert.Error(t, validateUnscopedTagIDs([]string{"tag-9"}, nil))
}