Repository navigation
fix: route TokenChunker delimiter_mode "one" to OneChunker in Go ingestion - #18121
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThe chunker factory now routes ChangesToken chunker routing
Estimated code review effort: 2 (Simple) | ~5 minutes Mergeability Score: ⚪ Minimal · up to This localized change routes the single-chunk configuration to the intended implementation and adds regression coverage; no actionable merge-blocking risk remains after normal checks and review. Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/service/tenant.go`:
- Around line 529-533: Update the model lookup in the tenant model validation
flow around GetModelByProviderIDAndInstanceIDAndModelName to use the existing
model-type mapping and the type-aware tenant-model DAO query, passing the
requested model type alongside provider, instance, and name. Add a regression
test covering an active same-name tenant_model row with a different model_type
and verify it is not returned for the requested type.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: f6e118d4-11e4-4b9f-b580-1f5535e29720
📒 Files selected for processing (3)
internal/ingestion/component/chunker/common.gointernal/ingestion/component/chunker/one_test.gointernal/service/tenant.go
| // Check if the model exists and is active. The tenant_model row is the | ||
| // source of truth here — providers with an empty factory catalog (e.g. | ||
| // OpenAI-API-Compatible, whose models are user-defined) cannot be | ||
| // validated against the catalog. Mirrors Python's _get_model_info. | ||
| modelEntity, err := s.modelDAO.GetModelByProviderIDAndInstanceIDAndModelName(ctx, dao.DB, modelProvider.ID, modelInstance.ID, modelName) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Preserve model-type validation when using tenant_model as the source of truth.
This lookup filters by provider, instance, and model name only. An active row for a different model_type can therefore satisfy a chat, embedding, or rerank lookup. The result can be returned under the wrong ModelType and passed to incompatible downstream code.
Use the existing model-type mapping and type-aware tenant-model query. Add a regression test for an active same-name row with the wrong type. (raw.githubusercontent.com)
Proposed fix
- modelEntity, err := s.modelDAO.GetModelByProviderIDAndInstanceIDAndModelName(ctx, dao.DB, modelProvider.ID, modelInstance.ID, modelName)
+ _, _, expectedModelType, err := tenantDefaultModelFields(modelType)
+ if err != nil {
+ return nil, nil, nil, false, err
+ }
+ modelEntity, err := s.modelDAO.GetByProviderIDAndInstanceIDAndModelTypeAndModelName(
+ ctx, dao.DB, modelProvider.ID, modelInstance.ID, int(expectedModelType), modelName,
+ )📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| // Check if the model exists and is active. The tenant_model row is the | |
| // source of truth here — providers with an empty factory catalog (e.g. | |
| // OpenAI-API-Compatible, whose models are user-defined) cannot be | |
| // validated against the catalog. Mirrors Python's _get_model_info. | |
| modelEntity, err := s.modelDAO.GetModelByProviderIDAndInstanceIDAndModelName(ctx, dao.DB, modelProvider.ID, modelInstance.ID, modelName) | |
| // Check if the model exists and is active. The tenant_model row is the | |
| // source of truth here — providers with an empty factory catalog (e.g. | |
| // OpenAI-API-Compatible, whose models are user-defined) cannot be | |
| // validated against the catalog. Mirrors Python's _get_model_info. | |
| _, _, expectedModelType, err := tenantDefaultModelFields(modelType) | |
| if err != nil { | |
| return nil, nil, nil, false, err | |
| } | |
| modelEntity, err := s.modelDAO.GetByProviderIDAndInstanceIDAndModelTypeAndModelName( | |
| ctx, dao.DB, modelProvider.ID, modelInstance.ID, int(expectedModelType), modelName, | |
| ) |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@internal/service/tenant.go` around lines 529 - 533, Update the model lookup
in the tenant model validation flow around
GetModelByProviderIDAndInstanceIDAndModelName to use the existing model-type
mapping and the type-aware tenant-model DAO query, passing the requested model
type alongside provider, instance, and name. Add a regression test covering an
active same-name tenant_model row with a different model_type and verify it is
not returned for the requested type.
Source: MCP tools
wangq8
left a comment
There was a problem hiding this comment.
Thanks for this fix! The root cause is well-identified and the fix at the newChunkerByName dispatch layer is clean — translating the DSL contract rather than relaxing schema validation is the right approach.
A few things to address:
1. Unrelated tenant.go changes
The internal/service/tenant.go changes (removing factoryModelTypeName and the factory model-type validation in GetModelInfo) are unrelated to the TokenChunker → OneChunker routing. These should be split into a separate PR with their own justification. Mixing fixes makes bisecting and reverting harder. If the factory catalog validation was blocking OpenAI-API-Compatible providers (as the comment suggests), that deserves its own change with appropriate context.
2. delimiter_mode value casing
The check mode == "one" is exact and case-sensitive. Is the web UI guaranteed to always emit lowercase "one"? If the DSL contract allows "One" or "ONE", this would miss it. Consider strings.EqualFold.
Otherwise LGTM — the test pins the translation well, and the fix is minimal and focused.
|
@euvre resolve conflict. |
…ntract shared by the web UI and the Python runtime expresses single-chunk mode as TokenChunker with delimiter_mode "one". In Go that behaviour lives in the OneChunker component, and TokenChunker's schema validation only accepts token_size/delimiter — so a knowledge base configured with the "One" method failed at canvas compile time (schema: field "delimiter_mode" has invalid value "one") and the ingestor kept retrying the task forever. Translate the contract at the chunker factory entry point: a TokenChunker component whose delimiter_mode is "one" now builds a OneChunker, keeping a single implementation path while preserving the DSL node id for progress tracking. Adds a regression test pinning the translation.
8c9192e to
c154974
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Summary
The DSL contract shared by the web UI and the Python runtime expresses single-chunk mode as a
TokenChunkernode withdelimiter_mode: "one". In Go that behaviour lives in the separateOneChunkercomponent, andTokenChunkerParam.Validateonly acceptstoken_size/delimiter. As a result, a knowledge base configured with the One method failed at canvas compile time:and the ingestor kept retrying the failed task indefinitely (the file appeared to be "parsing forever").
Fix: translate the contract at the single chunker factory entry point (
newChunkerByNameininternal/ingestion/component/chunker/common.go) — aTokenChunkercomponent whosedelimiter_modeis"one"now builds aOneChunker. This keeps one implementation path (no duplicated chunking logic), preserves the DSL node id (progress/log counting unaffected), and fixes both the ingestion pipeline and the agent canvas paths since they share the same registry factory. The strict constructor-level validation onTokenChunkeris unchanged.Adds a regression test (
TestNewChunkerByName_TokenChunkerOneMode) pinning the translation.bash build.sh --test ./internal/ingestion/component/chunker/...passes.