Skip to content

fix: search document node fails to fetch tags from the knowledge base - #8218

Merged
peslyn merged 1 commit into
v3from
pr@v3@fix_search_document_node_fails_to_fetch_tags_from_the_knowledge_base
Nov 30, 2026
Merged

peslyn merged 1 commit into
v3from
pr@v3@fix_search_document_node_fails_to_fetch_tags_from_the_knowledge_base

Conversation

@shaohuzhang1

Copy link
Copy Markdown
Contributor

fix: search document node fails to fetch tags from the knowledge base

return withCache(`knowledge-tags:${JSON.stringify(knowledgeIds)}`, () => requestApi.getAllTags!(knowledgeIds), force)
},
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff looks like an attempt to consolidate two duplicate tag APIs (getKnowledgeTags / getAllTags) into one, but there are several things to verify.

Potential issues

  1. Type/API inconsistency

    • getKnowledgeTags is removed from ApiModule, and the store’s getKnowledgeTags now calls requestApi.getAllTags.
    • Make sure ApiModule actually declares getAllTags:
      getAllTags?: (knowledgeIds: string[]) => Promise<KnowledgeTagGroup[]>
    • If it does not, this will be a TypeScript error: Property 'getAllTags' does not exist on type 'ApiModule'.
  2. Breaking change for store consumers

    • getAllTags is removed from WorkflowStoreApi and from the returned store object.
    • Any caller using workflowStore.getAllTags(...) will break at compile time and/or runtime.
    • If migration is incomplete, keep a deprecated alias temporarily:
      getAllTags(knowledgeIds: string[]) {
        return this.getKnowledgeTags(knowledgeIds)
      }
    • Otherwise, update all call sites and tests.
  3. Possible semantic regression

    • The store method is still named getKnowledgeTags, but it now delegates to requestApi.getAllTags.
    • Confirm that getAllTags has exactly the same semantics, return shape, and error behavior as the old getKnowledgeTags.
    • Also check all requestApi implementations: any adapter that only implements getKnowledgeTags and not getAllTags will now silently return [].
  4. Silent fallback hides missing implementation

    • if (!requestApi.getAllTags) return Promise.resolve([])
      This can hide a missing API implementation. Consider logging a warning in development, or making getAllTags required for scopes that need tag data.
  5. Cache key concerns

    • knowledge-tags:${JSON.stringify(knowledgeIds)} is order-sensitive. If ID order is not meaningful, sort a copy to improve cache hit rate:
      const key = `knowledge-tags:${[...knowledgeIds].sort().join(',')}`
    • Ensure withCache is scoped per resourceScope / workspace. If the cache is global, include the scope in the key.
    • Since the implementation switched from getKnowledgeTags to getAllTags, verify that reusing the same cache key is still correct.

Suggested cleanup

Use a local variable to avoid repeated optional access and the non-null assertion:

getKnowledgeTags(knowledgeIds: string[]): Promise<KnowledgeTagGroup[]> {
  const getAllTags = requestApi.getAllTags
  if (!getAllTags) return Promise.resolve([])

  const cacheKey = `knowledge-tags:${JSON.stringify(knowledgeIds)}`
  return withCache(cacheKey, () => getAllTags(knowledgeIds), force)
}

Summary

The diff is reasonable if:

  • ApiModule.getAllTags exists and is implemented everywhere,
  • all callers of store.getAllTags have been migrated,
  • getAllTags and getKnowledgeTags are semantically identical.

Otherwise, it can cause TypeScript errors, runtime fallbacks to empty arrays, or breaking changes for store consumers.

@peslyn
peslyn merged commit 69cbf04 into v3 Nov 30, 2026
3 of 4 checks passed
@peslyn
peslyn deleted the pr@v3@fix_search_document_node_fails_to_fetch_tags_from_the_knowledge_base branch November 30, 2026 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants