[Bug]: Wiki taxonomy embedding bypasses BATCH_EMBED_SIZE and exceeds provider input-count limits
Affected Component
Backend Service & API
Bug Description
Source-level bug report: Wiki taxonomy selection calls the embedding provider directly, bypassing the existing configurable batching path. Providers with a per-request input-count limit can therefore reject these requests even when the configured batch size is below that limit.
This report contains only public source references and hypothetical reproduction inputs. It does not include deployment details or production logs.
Public source references at revision 1edcd54b43606d9079bb36650efe3f68707a79ea:
batch.go:27–84:BatchEmbedWithPoolreadsBATCH_EMBED_SIZE, defaults to 5 when unset, and splits inputs before callingmodel.BatchEmbed.wiki_ingest_taxonomy.go:195–200:selectRelevantFoldersinstead callsembedder.BatchEmbed(ctx, folderTexts)andembedder.BatchEmbed(ctx, itemTexts)directly.openai.go:163:BatchEmbedputs the entiretextsslice into the request'sinputarray, without further splitting.
The folder and item calls consequently bypass the environment-controlled batch size. This is distinct from RPM/TPM rate limiting, single-text token limits, and vector-database write batching.
Steps to Reproduce
Proposed minimal synthetic reproduction, derived from the public code; this isolated fixture has not yet been executed:
- Configure an OpenAI-compatible mock embedding endpoint that rejects more than 20 input texts per HTTP request and otherwise returns one vector per input.
- Leave
BATCH_EMBED_SIZEunset so the public code's default of 5 applies. - Exercise
selectRelevantFolderswith nonempty taxonomy items and a folder pool of 80 distinct two-level paths. The pool exceedswikiTaxonomyFeedAllMaxFolders = 60, avoiding the early-return path. - Record the mock endpoint's request input count. The direct folder call submits all 80 texts instead of sub-batches of at most 5, so the mock rejects it.
- Cover the item call separately with more than 20 items: ensure the folder request can succeed, then check that the item request is also batched.
The numbers 20 and 80 above are synthetic test parameters, not production measurements.
Expected Behavior
Both Wiki taxonomy embedding calls should respect the same batching setting as the normal document indexing path, preserving vector count and order.
A possible minimal change is to reuse the existing batching interface for both calls:
folderVecs, err := embedder.BatchEmbedWithPool(ctx, embedder, folderTexts)
itemVecs, err := embedder.BatchEmbedWithPool(ctx, embedder, itemTexts)This is a proposed fix, not a tested patch. Regression coverage should check each provider request's input count, output ordering/count, both folder and item paths, and the existing fallback when a provider still fails.
Actual Behavior
As implemented in the linked source, the full folder or item slice is sent directly to BatchEmbed, and this call path does not consult BATCH_EMBED_SIZE.
When the provider returns an error, the folder branch logs a warning and returns capFolders(pool, wikiTaxonomyPromptMaxPaths). The item branch has the same fallback. Similarity-based selection is skipped; this does not imply that the entire document parse necessarily fails.
Reducing BATCH_EMBED_SIZE or worker concurrency cannot constrain the input count on a call that bypasses the batching helper.
WeKnora Version
Public source revision analyzed: 1edcd54b43606d9079bb36650efe3f68707a79ea. This is a backend source-level report; UI version is not applicable.
Deployment Method
Other — source-level analysis; the proposed reproduction uses a mock embedding endpoint and does not require a particular deployment method.
Operating System
Not applicable to the source-level finding; no OS-specific behavior is involved in the referenced call path.
Relevant Logs
No private deployment logs are included. The following warning text is quoted from the public source, not from a captured runtime log:
wiki ingest: taxonomy plan folder embed failed, feeding all folders: %vA regression fixture should assert that the mock provider never receives more inputs than the effective batch size. No runtime test result is claimed here.
Related but different: #2533 and #2953 concern embedding rate pacing/retry recovery. This report concerns Wiki taxonomy bypassing input-count batching.
Confirmation
- I have searched existing issues and confirmed this is a new one
Source: Tencent/WeKnora