Repository navigation
Feat: nats message processing refactor and support built in DSL - #16873
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds registry-backed built-in ingestion pipelines, exposes them through the API and frontend, moves tokenizer and chunk-field ownership into clearer stages, propagates processing errors, and hardens ingestion cancellation, settlement, shutdown, and terminal-state handling. ChangesBuilt-in pipeline catalog
Ingestion contracts and reliability
Estimated code review effort: 5 (Critical) | ~120 minutes Possibly related PRs
Suggested labels: Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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: 3
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
internal/ingestion/service/ingestion_service.go (2)
557-602: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
checkOncecan leak one blocked goroutine per tick under a stuckcancelCheck.Each 3s tick spawns a brand-new goroutine via
checkOnce()regardless of whether a prior tick's goroutine is still blocked one.cancelCheck(taskID)(e.g. a stuck DB/Redis call, exactly the scenario this refactor was designed to tolerate). Over a long-running or DB-degraded task, this accumulates one additional blocked goroutine (potentially holding a DB connection) every 3 seconds, per in-flight task — a real resource-exhaustion/cascading-outage risk rather than the intended bounded deadlock-avoidance.🔒 Suggested fix: reuse an in-flight check instead of spawning a new one each tick
func (e *Ingestor) pollCancel(taskID string, cancel context.CancelFunc, done <-chan struct{}) { + var pending <-chan bool checkOnce := func() <-chan bool { - result := make(chan bool, 1) - go func() { - defer func() { recover() }() // goroutine may outlive pollCancel; must not crash process - result <- e.cancelCheck(taskID) - }() - return result + if pending != nil { + return pending + } + result := make(chan bool, 1) + go func() { + defer func() { recover() }() // goroutine may outlive pollCancel; must not crash process + result <- e.cancelCheck(taskID) + }() + pending = result + return result } + consume := func() { pending = nil }Then call
consume()right after reading from eachcheckOnce()result (both the initial check and inside the ticker loop) so a fresh check is only started once the previous one has actually completed.🤖 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/ingestion/service/ingestion_service.go` around lines 557 - 602, Update Ingestor.pollCancel and its checkOnce flow to ensure only one cancelCheck goroutine is in flight at a time. Reuse the pending check result across ticker iterations, and consume the completed result immediately in both the initial check and ticker paths before starting another check; preserve cancellation and done-channel behavior.
1-1: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winDuplicate Redis cancel-flag-clear logic in
ingestion_service.go. Both sites wraprc.Delete(fmt.Sprintf("%s-cancel", id))incommon.BestEffortwith a callback that always returnsnil(sinceDelete's bool can't distinguish "not found" from "error" and already logs internally) — the same snippet, duplicated verbatim.
internal/ingestion/service/ingestion_service.go#L326-342: extract a private helper, e.g.e.clearCancelFlag(taskID, label string), that wraps theredis2.Get()nil-check +BestEffort+Deletecall once, and call it here.internal/ingestion/service/ingestion_service.go#L371-384: call the same newe.clearCancelFlag(task.ID, "clear stale cancel flag")helper instead of repeating the block.♻️ Proposed helper
+// clearCancelFlag deletes the Redis cancel-flag for taskID on a best-effort +// basis. Delete's bool return doesn't distinguish "not found" from "error", +// and Redis errors are already logged internally by Delete, so failures +// here are not surfaced further. +func (e *Ingestor) clearCancelFlag(taskID, label string) { + rc := redis2.Get() + if rc == nil { + return + } + common.BestEffort(fmt.Sprintf("%s for %s", label, taskID), func() error { + rc.Delete(fmt.Sprintf("%s-cancel", taskID)) + return nil + }) +}Then replace both inline blocks with
e.clearCancelFlag(taskID, "clear cancel flag")ande.clearCancelFlag(task.ID, "clear stale cancel flag")respectively.As per coding guidelines,
internal/ingestion/**/*.goshould "collapse duplicate paths and do not preserve transitional wrappers or deprecated APIs."🤖 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/ingestion/service/ingestion_service.go` at line 1, The Redis cancel-flag cleanup is duplicated at both ingestion call sites. Add a private `clearCancelFlag(taskID, label string)` method on the ingestion service that performs the `redis2.Get()` nil check and `common.BestEffort`-wrapped `Delete` once, then replace the inline blocks near the task cleanup paths with calls using `"clear cancel flag"` and `"clear stale cancel flag"` respectively.Source: Coding guidelines
🧹 Nitpick comments (3)
internal/ingestion/pipeline/pipeline.go (1)
439-447: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winInconsistent error handling in
cleanupCheckpointvs BestEffort pattern.
cleanupCheckpointstill uses the old pattern:_ = tracker.ClearInterruptID(ctx, cpID)silently swallows errors, while the rest of this file now wraps the same operation withcommon.BestEffort(e.g., line 398). Consider updating for consistency so tracker failures in the cancellation cleanup path are also logged rather than silently dropped.♻️ Suggested refactor for consistency
func (p *Pipeline) cleanupCheckpoint(ctx context.Context, store canvas.CheckPointStore, tracker *canvas.RunTracker, cpID string) { if store != nil { - if err := store.Delete(ctx, cpID); err != nil { - common.Error(fmt.Sprintf("pipeline: delete checkpoint %s failed: %v", cpID, err), err) - } + common.BestEffort(fmt.Sprintf("delete checkpoint %s", cpID), func() error { return store.Delete(ctx, cpID) }) } if tracker != nil { - _ = tracker.ClearInterruptID(ctx, cpID) + common.BestEffort(fmt.Sprintf("ClearInterruptID for %s", p.taskID), func() error { return tracker.ClearInterruptID(ctx, cpID) }) } }🤖 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/ingestion/pipeline/pipeline.go` around lines 439 - 447, Update cleanupCheckpoint to invoke tracker.ClearInterruptID through common.BestEffort instead of discarding its error with an underscore assignment. Preserve the existing nil check and cleanup flow, using the same error-logging pattern already established elsewhere in the file.internal/utility/keywords.go (1)
21-24: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove Python migration-history references from documentation comments. Multiple comments reference the Python implementation (
task_executor.run_dataflow:879,kwargs.get("chunks")) instead of describing the current Go behavior. Per coding guidelines, documentation comments should be aligned with the current runtime path rather than migration history.
internal/utility/keywords.go#L21-L24: Remove "Mirrors Python task_executor.run_dataflow:879 re.split(r"[,,;;、\r\n]+", keywords)." from thekeywordsSplitREcomment.internal/utility/keywords.go#L27-L31: Remove "Mirrors Python task_executor.run_dataflow:879." from theSplitKeywordsdoc comment.internal/utility/keywords_test.go#L21-L22: Remove the Python reference comment block aboveTestSplitKeywords_Comma.internal/ingestion/component/tokenizer_unit_test.go#L164-L166: Rephrase "matches pythonkwargs.get("chunks")with None" to describe the Go behavior (e.g., "nil chunks list is treated as zero-length").🤖 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/utility/keywords.go` around lines 21 - 24, Remove migration-history references from comments: in internal/utility/keywords.go lines 21-24 and 27-31, delete the Python implementation references; in internal/utility/keywords_test.go lines 21-22, remove the Python reference block above TestSplitKeywords_Comma; and in internal/ingestion/component/tokenizer_unit_test.go lines 164-166, rephrase the comment to describe that a nil chunks list is treated as zero-length.Source: Coding guidelines
internal/ingestion/component/tokenizer_unit_test.go (1)
134-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove dead code in
TestTokenizerComponent_Invoke_EmptyChunks.
var err erroris always nil at this point (it's first assigned on line 142 byc.Invoke), so theif err != nilblock is unreachable.withStubEmbedderalready handles construction errors viat.Fatalf. The_ = stubdiscard is also unnecessary sincestubis used at line 153.♻️ Proposed fix
func TestTokenizerComponent_Invoke_EmptyChunks(t *testing.T) { c, stub := withStubEmbedder(t, 4) - _ = stub - var err error - if err != nil { - t.Fatalf("NewTokenizerComponent: %v", err) - } out, err := c.Invoke(context.Background(), map[string]any{ "output_format": "chunks", "chunks": []map[string]any{}, })🤖 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/ingestion/component/tokenizer_unit_test.go` around lines 134 - 140, Remove the unused `var err error` declaration and its unreachable `if err != nil` failure block from `TestTokenizerComponent_Invoke_EmptyChunks`. Also remove the unnecessary `_ = stub` discard, keeping the existing `c` and `stub` usage unchanged.Source: Coding guidelines
🤖 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/ingestion/service/ingestion_service.go`:
- Around line 472-516: Update safeGetTerminal’s deferred panic recovery to
capture the recovered value and log the failure with relevant task context
before returning the documented fallback (false, false). Preserve the existing
successful DB-status evaluation and error fallback behavior.
In `@internal/ingestion/task/chunk_process.go`:
- Around line 107-129: Update cleanupConsumedChunkFields so the questions branch
uses the same empty-part filtering behavior as the keywords branch, replacing
the direct strings.Split assignment while preserving the existing question_kwd
presence check and source-field deletion.
In `@internal/service/ingestion_task_service.go`:
- Around line 243-265: Extract the shared terminal-marking flow from
MarkCompleted, MarkFailed, and MarkStopped into one private helper such as
markTerminal(taskID, target string). The helper should fetch the task, return
nil for any terminal status (COMPLETED, STOPPED, or FAILED), and otherwise call
transition with the requested target; update all three public methods to
delegate to it and remove their duplicated logic.
---
Outside diff comments:
In `@internal/ingestion/service/ingestion_service.go`:
- Around line 557-602: Update Ingestor.pollCancel and its checkOnce flow to
ensure only one cancelCheck goroutine is in flight at a time. Reuse the pending
check result across ticker iterations, and consume the completed result
immediately in both the initial check and ticker paths before starting another
check; preserve cancellation and done-channel behavior.
- Line 1: The Redis cancel-flag cleanup is duplicated at both ingestion call
sites. Add a private `clearCancelFlag(taskID, label string)` method on the
ingestion service that performs the `redis2.Get()` nil check and
`common.BestEffort`-wrapped `Delete` once, then replace the inline blocks near
the task cleanup paths with calls using `"clear cancel flag"` and `"clear stale
cancel flag"` respectively.
---
Nitpick comments:
In `@internal/ingestion/component/tokenizer_unit_test.go`:
- Around line 134-140: Remove the unused `var err error` declaration and its
unreachable `if err != nil` failure block from
`TestTokenizerComponent_Invoke_EmptyChunks`. Also remove the unnecessary `_ =
stub` discard, keeping the existing `c` and `stub` usage unchanged.
In `@internal/ingestion/pipeline/pipeline.go`:
- Around line 439-447: Update cleanupCheckpoint to invoke
tracker.ClearInterruptID through common.BestEffort instead of discarding its
error with an underscore assignment. Preserve the existing nil check and cleanup
flow, using the same error-logging pattern already established elsewhere in the
file.
In `@internal/utility/keywords.go`:
- Around line 21-24: Remove migration-history references from comments: in
internal/utility/keywords.go lines 21-24 and 27-31, delete the Python
implementation references; in internal/utility/keywords_test.go lines 21-22,
remove the Python reference block above TestSplitKeywords_Comma; and in
internal/ingestion/component/tokenizer_unit_test.go lines 164-166, rephrase the
comment to describe that a nil chunks list is treated as zero-length.
🪄 Autofix (Beta)
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
Run ID: d698edc6-7894-4caa-95ba-1d2d5e4d94df
📒 Files selected for processing (27)
internal/common/best_effort_test.gointernal/common/logger.gointernal/ingestion/component/tokenizer.gointernal/ingestion/component/tokenizer_test.gointernal/ingestion/component/tokenizer_unit_test.gointernal/ingestion/pipeline/pipeline.gointernal/ingestion/service/doc_state.gointernal/ingestion/service/execute_task_ack_test.gointernal/ingestion/service/ingestion_service.gointernal/ingestion/service/ingestor_lifecycle_test.gointernal/ingestion/task/chunk_index_writer.gointernal/ingestion/task/chunk_process.gointernal/ingestion/task/chunk_process_test.gointernal/ingestion/task/chunk_utils.gointernal/ingestion/task/chunk_utils_test.gointernal/ingestion/task/embedder.gointernal/ingestion/task/golden_compare.gointernal/ingestion/task/golden_compare_test.gointernal/ingestion/task/pipeline_executor.gointernal/ingestion/task/pipeline_executor_defaults.gointernal/ingestion/task/pipeline_executor_test.gointernal/ingestion/task/task_context.gointernal/ingestion/task/tool/compare_pipeline_golden.gointernal/service/ingestion_task_service.gointernal/service/ingestion_task_service_test.gointernal/utility/keywords.gointernal/utility/keywords_test.go
| // A panic in body is recovered: the task is marked FAILED and the message is | ||
| // Nacked for redelivery, so a single task's panic never crashes the worker. | ||
| // Settlement queries the DB for the task's actual status: a terminal state | ||
| // (COMPLETED/STOPPED/FAILED) means Ack; anything else means Nack. The body's | ||
| // return value is advisory only — DB truth is authoritative (BP1). | ||
| func (e *Ingestor) settleMessage(taskCtx *taskpkg.TaskContext, body func(context.Context) bool) (terminal bool) { | ||
| stop := e.startHeartbeat(taskCtx) | ||
| defer func() { | ||
| stop() // stop heartbeat (and wait) before ack/nack | ||
| if r := recover(); r != nil { | ||
| // Recover the panic so the worker process survives. Mark the | ||
| // task FAILED so a redelivery does not re-run a poison message | ||
| // (processMessage Ack-skips an already-FAILED task); Nack for | ||
| // redelivery. The broker's redelivery limit handles deterministic | ||
| // poison messages. | ||
| common.Error(fmt.Sprintf("task %s panicked: %v", taskCtx.IngestionTask.ID, r), fmt.Errorf("%v", r)) | ||
| e.markFailed(taskCtx.IngestionTask.ID) | ||
| terminal = false | ||
| } | ||
| // Settlement authority is the DB, not the in-memory bool (BP1). | ||
| // Fall back to the in-memory bool only when the DB is unavailable. | ||
| if dbTerminal, ok := e.safeGetTerminal(taskCtx.IngestionTask.ID); ok { | ||
| terminal = dbTerminal | ||
| } | ||
| e.ackOrNack(taskCtx, terminal) | ||
| }() | ||
| terminal = body(taskCtx.Ctx) | ||
| return | ||
| } | ||
|
|
||
| // safeGetTerminal queries the DB for the task's actual status and returns | ||
| // whether it is terminal (COMPLETED/STOPPED/FAILED). A recover guards | ||
| // against nil-DB panics in test environments — in that case (false, false) | ||
| // is returned so the caller falls back to the in-memory bool. | ||
| func (e *Ingestor) safeGetTerminal(taskID string) (terminal bool, ok bool) { | ||
| defer func() { recover() }() | ||
| task, err := e.ingestionTaskSvc.GetTask(taskID) | ||
| if err != nil { | ||
| return false, false | ||
| } | ||
| return task.Status == common.COMPLETED || | ||
| task.Status == common.STOPPED || | ||
| task.Status == common.FAILED, true | ||
| } | ||
|
|
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
safeGetTerminal silently swallows any panic.
The defer func() { recover() }() at Line 507 discards the recovered value entirely — no log line. If GetTask (or a future change) ever panics for a non-test reason, this failure mode becomes invisible, hiding real bugs behind the documented "fall back to in-memory bool" behavior.
🩹 Suggested fix
func (e *Ingestor) safeGetTerminal(taskID string) (terminal bool, ok bool) {
- defer func() { recover() }()
+ defer func() {
+ if r := recover(); r != nil {
+ common.Error(fmt.Sprintf("safeGetTerminal panicked for task %s: %v", taskID, r), fmt.Errorf("%v", r))
+ }
+ }()
task, err := e.ingestionTaskSvc.GetTask(taskID)📝 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.
| // A panic in body is recovered: the task is marked FAILED and the message is | |
| // Nacked for redelivery, so a single task's panic never crashes the worker. | |
| // Settlement queries the DB for the task's actual status: a terminal state | |
| // (COMPLETED/STOPPED/FAILED) means Ack; anything else means Nack. The body's | |
| // return value is advisory only — DB truth is authoritative (BP1). | |
| func (e *Ingestor) settleMessage(taskCtx *taskpkg.TaskContext, body func(context.Context) bool) (terminal bool) { | |
| stop := e.startHeartbeat(taskCtx) | |
| defer func() { | |
| stop() // stop heartbeat (and wait) before ack/nack | |
| if r := recover(); r != nil { | |
| // Recover the panic so the worker process survives. Mark the | |
| // task FAILED so a redelivery does not re-run a poison message | |
| // (processMessage Ack-skips an already-FAILED task); Nack for | |
| // redelivery. The broker's redelivery limit handles deterministic | |
| // poison messages. | |
| common.Error(fmt.Sprintf("task %s panicked: %v", taskCtx.IngestionTask.ID, r), fmt.Errorf("%v", r)) | |
| e.markFailed(taskCtx.IngestionTask.ID) | |
| terminal = false | |
| } | |
| // Settlement authority is the DB, not the in-memory bool (BP1). | |
| // Fall back to the in-memory bool only when the DB is unavailable. | |
| if dbTerminal, ok := e.safeGetTerminal(taskCtx.IngestionTask.ID); ok { | |
| terminal = dbTerminal | |
| } | |
| e.ackOrNack(taskCtx, terminal) | |
| }() | |
| terminal = body(taskCtx.Ctx) | |
| return | |
| } | |
| // safeGetTerminal queries the DB for the task's actual status and returns | |
| // whether it is terminal (COMPLETED/STOPPED/FAILED). A recover guards | |
| // against nil-DB panics in test environments — in that case (false, false) | |
| // is returned so the caller falls back to the in-memory bool. | |
| func (e *Ingestor) safeGetTerminal(taskID string) (terminal bool, ok bool) { | |
| defer func() { recover() }() | |
| task, err := e.ingestionTaskSvc.GetTask(taskID) | |
| if err != nil { | |
| return false, false | |
| } | |
| return task.Status == common.COMPLETED || | |
| task.Status == common.STOPPED || | |
| task.Status == common.FAILED, true | |
| } | |
| // A panic in body is recovered: the task is marked FAILED and the message is | |
| // Nacked for redelivery, so a single task's panic never crashes the worker. | |
| // Settlement queries the DB for the task's actual status: a terminal state | |
| // (COMPLETED/STOPPED/FAILED) means Ack; anything else means Nack. The body's | |
| // return value is advisory only — DB truth is authoritative (BP1). | |
| func (e *Ingestor) settleMessage(taskCtx *taskpkg.TaskContext, body func(context.Context) bool) (terminal bool) { | |
| stop := e.startHeartbeat(taskCtx) | |
| defer func() { | |
| stop() // stop heartbeat (and wait) before ack/nack | |
| if r := recover(); r != nil { | |
| // Recover the panic so the worker process survives. Mark the | |
| // task FAILED so a redelivery does not re-run a poison message | |
| // (processMessage Ack-skips an already-FAILED task); Nack for | |
| // redelivery. The broker's redelivery limit handles deterministic | |
| // poison messages. | |
| common.Error(fmt.Sprintf("task %s panicked: %v", taskCtx.IngestionTask.ID, r), fmt.Errorf("%v", r)) | |
| e.markFailed(taskCtx.IngestionTask.ID) | |
| terminal = false | |
| } | |
| // Settlement authority is the DB, not the in-memory bool (BP1). | |
| // Fall back to the in-memory bool only when the DB is unavailable. | |
| if dbTerminal, ok := e.safeGetTerminal(taskCtx.IngestionTask.ID); ok { | |
| terminal = dbTerminal | |
| } | |
| e.ackOrNack(taskCtx, terminal) | |
| }() | |
| terminal = body(taskCtx.Ctx) | |
| return | |
| } | |
| // safeGetTerminal queries the DB for the task's actual status and returns | |
| // whether it is terminal (COMPLETED/STOPPED/FAILED). A recover guards | |
| // against nil-DB panics in test environments — in that case (false, false) | |
| // is returned so the caller falls back to the in-memory bool. | |
| func (e *Ingestor) safeGetTerminal(taskID string) (terminal bool, ok bool) { | |
| defer func() { | |
| if r := recover(); r != nil { | |
| common.Error(fmt.Sprintf("safeGetTerminal panicked for task %s: %v", taskID, r), fmt.Errorf("%v", r)) | |
| } | |
| }() | |
| task, err := e.ingestionTaskSvc.GetTask(taskID) | |
| if err != nil { | |
| return false, false | |
| } | |
| return task.Status == common.COMPLETED || | |
| task.Status == common.STOPPED || | |
| task.Status == common.FAILED, true | |
| } |
🤖 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/ingestion/service/ingestion_service.go` around lines 472 - 516,
Update safeGetTerminal’s deferred panic recovery to capture the recovered value
and log the failure with relevant task context before returning the documented
fallback (false, false). Preserve the existing successful DB-status evaluation
and error fallback behavior.
| func (s *IngestionTaskService) MarkCompleted(taskID string) error { | ||
| _, err := s.transition(taskID, common.COMPLETED) | ||
| task, err := s.GetTask(taskID) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if task.Status == common.COMPLETED || task.Status == common.STOPPED || task.Status == common.FAILED { | ||
| return nil // already terminal, idempotent — mirrors MarkStopped | ||
| } | ||
| _, err = s.transition(taskID, common.COMPLETED) | ||
| return err | ||
| } | ||
|
|
||
| func (s *IngestionTaskService) MarkFailed(taskID string) error { | ||
| _, err := s.transition(taskID, common.FAILED) | ||
| task, err := s.GetTask(taskID) | ||
| if err != nil { | ||
| return err | ||
| } | ||
| if task.Status == common.FAILED || task.Status == common.COMPLETED || task.Status == common.STOPPED { | ||
| return nil // already terminal, idempotent — mirrors MarkStopped | ||
| } | ||
| _, err = s.transition(taskID, common.FAILED) | ||
| return err | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Converge the triplicated Mark idempotency pattern into one helper.*
MarkCompleted, MarkFailed, and the pre-existing MarkStopped (Lines 270-280) now all follow the identical shape: fetch the task, short-circuit nil if already in one of the three terminal states, otherwise call transition. Extracting a shared private helper (e.g. markTerminal(taskID, target string) error) would remove the triplication and give a single place to fix/extend the terminal-state list later.
♻️ Proposed refactor
+func (s *IngestionTaskService) markTerminal(taskID string, target string) error {
+ task, err := s.GetTask(taskID)
+ if err != nil {
+ return err
+ }
+ if task.Status == common.COMPLETED || task.Status == common.STOPPED || task.Status == common.FAILED {
+ return nil // already terminal, idempotent
+ }
+ _, err = s.transition(taskID, target)
+ return err
+}
+
func (s *IngestionTaskService) MarkCompleted(taskID string) error {
- task, err := s.GetTask(taskID)
- if err != nil {
- return err
- }
- if task.Status == common.COMPLETED || task.Status == common.STOPPED || task.Status == common.FAILED {
- return nil // already terminal, idempotent — mirrors MarkStopped
- }
- _, err = s.transition(taskID, common.COMPLETED)
- return err
+ return s.markTerminal(taskID, common.COMPLETED)
}
func (s *IngestionTaskService) MarkFailed(taskID string) error {
- task, err := s.GetTask(taskID)
- if err != nil {
- return err
- }
- if task.Status == common.FAILED || task.Status == common.COMPLETED || task.Status == common.STOPPED {
- return nil // already terminal, idempotent — mirrors MarkStopped
- }
- _, err = s.transition(taskID, common.FAILED)
- return err
+ return s.markTerminal(taskID, common.FAILED)
}(and similarly for MarkStopped)
🤖 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/ingestion_task_service.go` around lines 243 - 265, Extract
the shared terminal-marking flow from MarkCompleted, MarkFailed, and MarkStopped
into one private helper such as markTerminal(taskID, target string). The helper
should fetch the task, return nil for any terminal status (COMPLETED, STOPPED,
or FAILED), and otherwise call transition with the requested target; update all
three public methods to delegate to it and remove their duplicated logic.
Source: Coding guidelines
| // does not want the main flow interrupted by this failure. Use it for | ||
| // resource cleanup, soft-state deletion, and progress mirroring: operations | ||
| // whose failure must be visible (logged) but must not abort the task. | ||
| func BestEffort(label string, f func() error) { |
There was a problem hiding this comment.
Move BestEffort out of logger.go.
| } | ||
|
|
||
| func NewIngestor(name string, maxConcurrency int32, supportedTypes []string) *Ingestor { | ||
| if maxConcurrency <= 0 { |
There was a problem hiding this comment.
pipeline doesn't support maxConcurrency, remove it.
There was a problem hiding this comment.
As discussed, we need maxConcurrency settings. Should use CPU count
There was a problem hiding this comment.
if no maxConcurrency, use CPU count
| stop := e.startHeartbeat(taskCtx) | ||
| defer func() { | ||
| stop() // stop heartbeat (and wait) before ack/nack | ||
| if r := recover(); r != nil { |
There was a problem hiding this comment.
panic/recover is a bad practice. Shall avoid panic everywhere.
There was a problem hiding this comment.
Actionable comments posted: 13
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
internal/service/document.go (1)
2620-2637: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winApply registry validation to
parser_idas well.Only
chunk_methodis validated. A request usingparser_idcan still provide an unknown value and reachresetDocumentForReparse, causing ingestion to fail later.Proposed fix
- if present["parser_id"] && req.ParserID != nil { + if present["parser_id"] { + if req.ParserID == nil || strings.TrimSpace(*req.ParserID) == "" { + return common.CodeDataError, errors.New("`parser_id` is not valid") + } parserID := strings.TrimSpace(*req.ParserID) + if err := validateParserID(parserID); err != nil { + return common.CodeDataError, err + } if (doc.Type == "visual" && parserID != "picture") || (isPresentationFile(doc.Name) && parserID != "presentation") {🤖 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/document.go` around lines 2620 - 2637, Update the parser_id handling in the document validation flow to call validateParserID on the trimmed value before the existing type-specific checks, returning the same data-error response for unknown parser IDs. Keep the current visual and presentation restrictions unchanged.internal/ingestion/service/execute_task_test.go (1)
107-141: 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy liftAssert the builtin DSL path ran.
internal/ingestion/service/execute_task_test.go:125-140only excludesno pipeline_id; registry, alias-resolution, or DSL-loading failures could still pass. Add a loader/executor spy or another builtin-path sentinel before asserting the expected storage failure.🤖 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/ingestion/service/execute_task_test.go` around lines 107 - 141, Strengthen TestDefaultRunDocumentTask_ParserIDWithoutPipelineID to positively verify the builtin DSL path executed, rather than only excluding a missing-pipeline error. Add a loader or executor spy/sentinel covering the embedded registry resolution, naive-to-general alias handling, or DSL loading, and assert that it was invoked before validating the expected downstream storage failure.
🧹 Nitpick comments (3)
internal/ingestion/pipeline/builtin_registry_test.go (1)
63-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration residue now that the registry owns parser validation.
internal/ingestion/pipeline/builtin_registry_test.go#L63-L126: delete the obsolete copied hardcoded-list comparison.internal/ingestion/pipeline/builtin_registry.go#L38-L42: document only the current alias/listing contract.internal/ingestion/pipeline/builtin_registry.go#L98-L101: remove hardcoded-list migration history.internal/ingestion/pipeline/builtin_registry.go#L163-L165: describe current accepted-ID behavior without migration wording.As per coding guidelines, remove dead tests and keep Go documentation aligned with the current runtime path rather than migration history.
🤖 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/ingestion/pipeline/builtin_registry_test.go` around lines 63 - 126, Remove the obsolete TestRegistryVsHardcodedList test from internal/ingestion/pipeline/builtin_registry_test.go. In internal/ingestion/pipeline/builtin_registry.go, update the documentation at lines 38-42 and 163-165 to describe only the current alias, listing, and accepted-ID behavior, and remove the migration-history text at lines 98-101; no runtime behavior changes are needed.Source: Coding guidelines
internal/ingestion/pipeline/template/ingestion_pipeline_qa.json (1)
183-193: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign the edge IDs with the Q&A chunker.
Both IDs still name
TokenChunker:BraveBirdsSing, while their endpoints useQAChunker:TidyCloudsThink. Keep serialized graph metadata consistent:Proposed fix
- "id": "xy-edge__Parser:HipSignsRhymestart-TokenChunker:BraveBirdsSingend", + "id": "xy-edge__Parser:HipSignsRhymestart-QAChunker:TidyCloudsThinkend", ... - "id": "xy-edge__TokenChunker:BraveBirdsSingstart-Tokenizer:ColdCloudsDreamend", + "id": "xy-edge__QAChunker:TidyCloudsThinkstart-Tokenizer:ColdCloudsDreamend",As per coding guidelines, remove stale or duplicate implementation artifacts.
🤖 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/ingestion/pipeline/template/ingestion_pipeline_qa.json` around lines 183 - 193, Update the two edge id values around the Parser:HipSignsRhyme and Tokenizer:ColdCloudsDream endpoints so they reference QAChunker:TidyCloudsThink instead of the stale TokenChunker:BraveBirdsSing identifier. Keep each id consistent with its existing source and target endpoints, and remove any stale duplicate identifier text.Source: Coding guidelines
internal/utility/split.go (1)
24-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the Python migration-history commentary.
Document the current delimiter and nil semantics directly; references to Python line numbers and intentional migration divergence will become stale.
As per coding guidelines, “keep package and documentation comments aligned with the current runtime path rather than migration history.”
Also applies to: 59-67
🤖 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/utility/split.go` around lines 24 - 27, Update the comments around keywordsSplitRE and the related split logic to describe only the current delimiters and nil semantics. Remove Python file, line-number, migration-history, and divergence references while preserving accurate documentation of the runtime behavior.Source: Coding guidelines
🤖 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 `@cmd/ragflow_server.go`:
- Line 41: Make the concurrency passed to NewIngestor configurable by adding a
dedicated setting or flag with a conservative default and an upper bound, then
use that value at the current runtime.NumCPU() call site instead of deriving
workers directly from host CPU count. Retain NewIngestor’s maxConcurrency
parameter and enforce the cap before constructing the ingestor.
In `@internal/common/parser_config.go`:
- Around line 110-112: Update the defaults merge in
internal/common/parser_config.go at lines 110-112 so both canonical general and
persisted naive identifiers resolve to the same general-purpose defaults through
the registry alias. Update
internal/ingestion/pipeline/template/ingestion_pipeline_general.json at lines
445-447 to declare general instead of naive, relying on the registry alias for
legacy rows.
In `@internal/handler/pipeline.go`:
- Around line 42-52: Treat the built-in pipeline registry as required: change
NewPipelineHandler in internal/handler/pipeline.go to return initialization
errors, remove the empty-catalog fallback in its handler path, require
successful handler construction and register the route unconditionally in
internal/router/router.go, and have internal/service/dataset.go use the
initialized registry directly instead of converting initialization failures into
client errors.
- Around line 66-71: Update the pipeline type handling around pipelineType and
the registry listing so empty or "builtin" requests continue returning
h.registry.List(), while any other value returns a data error through the
existing common response mechanism. Remove the speculative comment and
unused-value suppression rather than retaining migration-oriented branches.
In `@internal/ingestion/pipeline/builtin_registry.go`:
- Around line 159-160: Update the registry return path around the visible
template copy to recursively deep-clone tpl.DSL, including nested maps and
slices, before returning the template so callers cannot mutate the process-wide
registry. Preserve the existing lookup result behavior and add a test verifying
mutations to the returned DSL do not affect subsequent registry retrievals.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_laws.json`:
- Line 160: Replace the invalid `{,2}` quantifier with `{1,2}` in all affected
matching templates:
internal/ingestion/pipeline/template/ingestion_pipeline_laws.json at lines
160-160 and 405-405,
internal/ingestion/pipeline/template/ingestion_pipeline_manual.json at lines
121-121 and 344-344, and the corresponding patterns in
internal/ingestion/pipeline/template/ingestion_pipeline_book.json and
internal/ingestion/pipeline/template/ingestion_pipeline_paper.json.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_paper.json`:
- Line 108: Update the marker regex in the ingestion pipeline template to use
the valid one-to-two-digit quantifier `[0-9]{1,2}` instead of `[0-9]{,2}`,
preserving the surrounding parenthesis matching.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json`:
- Around line 8-11: Update the English, German, and Chinese description values
in the ingestion pipeline presentation template to remove the unsupported
Keynote format claim. Keep the existing descriptions and supported
PowerPoint/PDF-related wording unchanged, without adding .key support.
In `@internal/service/dataset_parser_test.go`:
- Around line 24-31: The TestValidateParserID_AcceptsRegistryRefs test does not
cover the complete canonical pipeline catalog. Extend its table of IDs to
include email, laws, manual, one, paper, picture, presentation, and resume while
preserving the existing validation assertions.
In `@internal/service/dataset.go`:
- Around line 3052-3064: Update validateParserID in internal/service/dataset.go
to resolve accepted legacy aliases to their canonical pipeline IDs and return
that canonical value for persistence, rather than only validating the input;
update all callers as needed to use the returned ID. In
internal/service/dataset_parser_test.go lines 34-41, remove new-write
compatibility coverage for “naive” and move it to loading existing pipeline
data, preserving legacy read behavior without retaining compatibility-only
validation surfaces.
In `@internal/utility/split.go`:
- Around line 68-72: Update SplitQuestions to treat CRLF and LF as equivalent
question separators, ensuring carriage returns are not retained in returned
question strings; add a test covering input such as “Q1\r\nQ2” and verify clean
indexed values.
In `@web/src/hooks/use-user-setting-request.tsx`:
- Around line 108-115: Replace the inline queryKey array in the useQuery call
with the domain PipelineKeys query-key factory, using its list-pipelines key and
preserving the existing query behavior. Ensure the factory returns the required
readonly tuple and reuse the same key for future invalidation consistency.
In `@web/src/services/knowledge-service.ts`:
- Around line 70-73: Update the listPipelines registration to use
registerNextServer with the request helper from `@/utils/next-request` instead of
the registerServer(..., request) mapping. Preserve the endpoint’s existing URL
and GET method configuration.
---
Outside diff comments:
In `@internal/ingestion/service/execute_task_test.go`:
- Around line 107-141: Strengthen
TestDefaultRunDocumentTask_ParserIDWithoutPipelineID to positively verify the
builtin DSL path executed, rather than only excluding a missing-pipeline error.
Add a loader or executor spy/sentinel covering the embedded registry resolution,
naive-to-general alias handling, or DSL loading, and assert that it was invoked
before validating the expected downstream storage failure.
In `@internal/service/document.go`:
- Around line 2620-2637: Update the parser_id handling in the document
validation flow to call validateParserID on the trimmed value before the
existing type-specific checks, returning the same data-error response for
unknown parser IDs. Keep the current visual and presentation restrictions
unchanged.
---
Nitpick comments:
In `@internal/ingestion/pipeline/builtin_registry_test.go`:
- Around line 63-126: Remove the obsolete TestRegistryVsHardcodedList test from
internal/ingestion/pipeline/builtin_registry_test.go. In
internal/ingestion/pipeline/builtin_registry.go, update the documentation at
lines 38-42 and 163-165 to describe only the current alias, listing, and
accepted-ID behavior, and remove the migration-history text at lines 98-101; no
runtime behavior changes are needed.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_qa.json`:
- Around line 183-193: Update the two edge id values around the
Parser:HipSignsRhyme and Tokenizer:ColdCloudsDream endpoints so they reference
QAChunker:TidyCloudsThink instead of the stale TokenChunker:BraveBirdsSing
identifier. Keep each id consistent with its existing source and target
endpoints, and remove any stale duplicate identifier text.
In `@internal/utility/split.go`:
- Around line 24-27: Update the comments around keywordsSplitRE and the related
split logic to describe only the current delimiters and nil semantics. Remove
Python file, line-number, migration-history, and divergence references while
preserving accurate documentation of the runtime behavior.
🪄 Autofix (Beta)
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
Run ID: 052b1f9d-b472-4f85-8db5-9d7a2abd0634
📒 Files selected for processing (39)
cmd/ragflow_server.gointernal/common/parser_config.gointernal/handler/dataset.gointernal/handler/pipeline.gointernal/handler/pipeline_test.gointernal/ingestion/pipeline/builtin_registry.gointernal/ingestion/pipeline/builtin_registry_test.gointernal/ingestion/pipeline/real_storage_integration_test.gointernal/ingestion/pipeline/template/ingestion_pipeline_audio.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_book.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_email.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_general.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_laws.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_manual.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_one.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_paper.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_picture.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_presentation.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_qa.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_resume.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_table.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_tag.jsoninternal/ingestion/pipeline/template_integration_test.gointernal/ingestion/service/execute_task_test.gointernal/ingestion/service/ingestion_service.gointernal/ingestion/task/chunk_process.gointernal/ingestion/task/pipeline_real_integration_test.gointernal/parser/parser/factory.gointernal/parser/parser/factory_test.gointernal/router/router.gointernal/service/dataset.gointernal/service/dataset_parser_test.gointernal/service/document.gointernal/utility/split.gointernal/utility/split_test.goweb/src/hooks/use-user-setting-request.tsxweb/src/locales/en.tsweb/src/services/knowledge-service.tsweb/src/utils/api.ts
💤 Files with no reviewable changes (3)
- internal/parser/parser/factory_test.go
- internal/parser/parser/factory.go
- internal/handler/dataset.go
There was a problem hiding this comment.
Caution
Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.
Actionable comments posted: 13
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
internal/service/document.go (1)
2620-2637: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winApply registry validation to
parser_idas well.Only
chunk_methodis validated. A request usingparser_idcan still provide an unknown value and reachresetDocumentForReparse, causing ingestion to fail later.Proposed fix
- if present["parser_id"] && req.ParserID != nil { + if present["parser_id"] { + if req.ParserID == nil || strings.TrimSpace(*req.ParserID) == "" { + return common.CodeDataError, errors.New("`parser_id` is not valid") + } parserID := strings.TrimSpace(*req.ParserID) + if err := validateParserID(parserID); err != nil { + return common.CodeDataError, err + } if (doc.Type == "visual" && parserID != "picture") || (isPresentationFile(doc.Name) && parserID != "presentation") {🤖 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/document.go` around lines 2620 - 2637, Update the parser_id handling in the document validation flow to call validateParserID on the trimmed value before the existing type-specific checks, returning the same data-error response for unknown parser IDs. Keep the current visual and presentation restrictions unchanged.internal/ingestion/service/execute_task_test.go (1)
107-141: 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy liftAssert the builtin DSL path ran.
internal/ingestion/service/execute_task_test.go:125-140only excludesno pipeline_id; registry, alias-resolution, or DSL-loading failures could still pass. Add a loader/executor spy or another builtin-path sentinel before asserting the expected storage failure.🤖 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/ingestion/service/execute_task_test.go` around lines 107 - 141, Strengthen TestDefaultRunDocumentTask_ParserIDWithoutPipelineID to positively verify the builtin DSL path executed, rather than only excluding a missing-pipeline error. Add a loader or executor spy/sentinel covering the embedded registry resolution, naive-to-general alias handling, or DSL loading, and assert that it was invoked before validating the expected downstream storage failure.
🧹 Nitpick comments (3)
internal/ingestion/pipeline/builtin_registry_test.go (1)
63-126: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove migration residue now that the registry owns parser validation.
internal/ingestion/pipeline/builtin_registry_test.go#L63-L126: delete the obsolete copied hardcoded-list comparison.internal/ingestion/pipeline/builtin_registry.go#L38-L42: document only the current alias/listing contract.internal/ingestion/pipeline/builtin_registry.go#L98-L101: remove hardcoded-list migration history.internal/ingestion/pipeline/builtin_registry.go#L163-L165: describe current accepted-ID behavior without migration wording.As per coding guidelines, remove dead tests and keep Go documentation aligned with the current runtime path rather than migration history.
🤖 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/ingestion/pipeline/builtin_registry_test.go` around lines 63 - 126, Remove the obsolete TestRegistryVsHardcodedList test from internal/ingestion/pipeline/builtin_registry_test.go. In internal/ingestion/pipeline/builtin_registry.go, update the documentation at lines 38-42 and 163-165 to describe only the current alias, listing, and accepted-ID behavior, and remove the migration-history text at lines 98-101; no runtime behavior changes are needed.Source: Coding guidelines
internal/ingestion/pipeline/template/ingestion_pipeline_qa.json (1)
183-193: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAlign the edge IDs with the Q&A chunker.
Both IDs still name
TokenChunker:BraveBirdsSing, while their endpoints useQAChunker:TidyCloudsThink. Keep serialized graph metadata consistent:Proposed fix
- "id": "xy-edge__Parser:HipSignsRhymestart-TokenChunker:BraveBirdsSingend", + "id": "xy-edge__Parser:HipSignsRhymestart-QAChunker:TidyCloudsThinkend", ... - "id": "xy-edge__TokenChunker:BraveBirdsSingstart-Tokenizer:ColdCloudsDreamend", + "id": "xy-edge__QAChunker:TidyCloudsThinkstart-Tokenizer:ColdCloudsDreamend",As per coding guidelines, remove stale or duplicate implementation artifacts.
🤖 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/ingestion/pipeline/template/ingestion_pipeline_qa.json` around lines 183 - 193, Update the two edge id values around the Parser:HipSignsRhyme and Tokenizer:ColdCloudsDream endpoints so they reference QAChunker:TidyCloudsThink instead of the stale TokenChunker:BraveBirdsSing identifier. Keep each id consistent with its existing source and target endpoints, and remove any stale duplicate identifier text.Source: Coding guidelines
internal/utility/split.go (1)
24-27: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winRemove the Python migration-history commentary.
Document the current delimiter and nil semantics directly; references to Python line numbers and intentional migration divergence will become stale.
As per coding guidelines, “keep package and documentation comments aligned with the current runtime path rather than migration history.”
Also applies to: 59-67
🤖 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/utility/split.go` around lines 24 - 27, Update the comments around keywordsSplitRE and the related split logic to describe only the current delimiters and nil semantics. Remove Python file, line-number, migration-history, and divergence references while preserving accurate documentation of the runtime behavior.Source: Coding guidelines
🤖 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 `@cmd/ragflow_server.go`:
- Line 41: Make the concurrency passed to NewIngestor configurable by adding a
dedicated setting or flag with a conservative default and an upper bound, then
use that value at the current runtime.NumCPU() call site instead of deriving
workers directly from host CPU count. Retain NewIngestor’s maxConcurrency
parameter and enforce the cap before constructing the ingestor.
In `@internal/common/parser_config.go`:
- Around line 110-112: Update the defaults merge in
internal/common/parser_config.go at lines 110-112 so both canonical general and
persisted naive identifiers resolve to the same general-purpose defaults through
the registry alias. Update
internal/ingestion/pipeline/template/ingestion_pipeline_general.json at lines
445-447 to declare general instead of naive, relying on the registry alias for
legacy rows.
In `@internal/handler/pipeline.go`:
- Around line 42-52: Treat the built-in pipeline registry as required: change
NewPipelineHandler in internal/handler/pipeline.go to return initialization
errors, remove the empty-catalog fallback in its handler path, require
successful handler construction and register the route unconditionally in
internal/router/router.go, and have internal/service/dataset.go use the
initialized registry directly instead of converting initialization failures into
client errors.
- Around line 66-71: Update the pipeline type handling around pipelineType and
the registry listing so empty or "builtin" requests continue returning
h.registry.List(), while any other value returns a data error through the
existing common response mechanism. Remove the speculative comment and
unused-value suppression rather than retaining migration-oriented branches.
In `@internal/ingestion/pipeline/builtin_registry.go`:
- Around line 159-160: Update the registry return path around the visible
template copy to recursively deep-clone tpl.DSL, including nested maps and
slices, before returning the template so callers cannot mutate the process-wide
registry. Preserve the existing lookup result behavior and add a test verifying
mutations to the returned DSL do not affect subsequent registry retrievals.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_laws.json`:
- Line 160: Replace the invalid `{,2}` quantifier with `{1,2}` in all affected
matching templates:
internal/ingestion/pipeline/template/ingestion_pipeline_laws.json at lines
160-160 and 405-405,
internal/ingestion/pipeline/template/ingestion_pipeline_manual.json at lines
121-121 and 344-344, and the corresponding patterns in
internal/ingestion/pipeline/template/ingestion_pipeline_book.json and
internal/ingestion/pipeline/template/ingestion_pipeline_paper.json.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_paper.json`:
- Line 108: Update the marker regex in the ingestion pipeline template to use
the valid one-to-two-digit quantifier `[0-9]{1,2}` instead of `[0-9]{,2}`,
preserving the surrounding parenthesis matching.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json`:
- Around line 8-11: Update the English, German, and Chinese description values
in the ingestion pipeline presentation template to remove the unsupported
Keynote format claim. Keep the existing descriptions and supported
PowerPoint/PDF-related wording unchanged, without adding .key support.
In `@internal/service/dataset_parser_test.go`:
- Around line 24-31: The TestValidateParserID_AcceptsRegistryRefs test does not
cover the complete canonical pipeline catalog. Extend its table of IDs to
include email, laws, manual, one, paper, picture, presentation, and resume while
preserving the existing validation assertions.
In `@internal/service/dataset.go`:
- Around line 3052-3064: Update validateParserID in internal/service/dataset.go
to resolve accepted legacy aliases to their canonical pipeline IDs and return
that canonical value for persistence, rather than only validating the input;
update all callers as needed to use the returned ID. In
internal/service/dataset_parser_test.go lines 34-41, remove new-write
compatibility coverage for “naive” and move it to loading existing pipeline
data, preserving legacy read behavior without retaining compatibility-only
validation surfaces.
In `@internal/utility/split.go`:
- Around line 68-72: Update SplitQuestions to treat CRLF and LF as equivalent
question separators, ensuring carriage returns are not retained in returned
question strings; add a test covering input such as “Q1\r\nQ2” and verify clean
indexed values.
In `@web/src/hooks/use-user-setting-request.tsx`:
- Around line 108-115: Replace the inline queryKey array in the useQuery call
with the domain PipelineKeys query-key factory, using its list-pipelines key and
preserving the existing query behavior. Ensure the factory returns the required
readonly tuple and reuse the same key for future invalidation consistency.
In `@web/src/services/knowledge-service.ts`:
- Around line 70-73: Update the listPipelines registration to use
registerNextServer with the request helper from `@/utils/next-request` instead of
the registerServer(..., request) mapping. Preserve the endpoint’s existing URL
and GET method configuration.
---
Outside diff comments:
In `@internal/ingestion/service/execute_task_test.go`:
- Around line 107-141: Strengthen
TestDefaultRunDocumentTask_ParserIDWithoutPipelineID to positively verify the
builtin DSL path executed, rather than only excluding a missing-pipeline error.
Add a loader or executor spy/sentinel covering the embedded registry resolution,
naive-to-general alias handling, or DSL loading, and assert that it was invoked
before validating the expected downstream storage failure.
In `@internal/service/document.go`:
- Around line 2620-2637: Update the parser_id handling in the document
validation flow to call validateParserID on the trimmed value before the
existing type-specific checks, returning the same data-error response for
unknown parser IDs. Keep the current visual and presentation restrictions
unchanged.
---
Nitpick comments:
In `@internal/ingestion/pipeline/builtin_registry_test.go`:
- Around line 63-126: Remove the obsolete TestRegistryVsHardcodedList test from
internal/ingestion/pipeline/builtin_registry_test.go. In
internal/ingestion/pipeline/builtin_registry.go, update the documentation at
lines 38-42 and 163-165 to describe only the current alias, listing, and
accepted-ID behavior, and remove the migration-history text at lines 98-101; no
runtime behavior changes are needed.
In `@internal/ingestion/pipeline/template/ingestion_pipeline_qa.json`:
- Around line 183-193: Update the two edge id values around the
Parser:HipSignsRhyme and Tokenizer:ColdCloudsDream endpoints so they reference
QAChunker:TidyCloudsThink instead of the stale TokenChunker:BraveBirdsSing
identifier. Keep each id consistent with its existing source and target
endpoints, and remove any stale duplicate identifier text.
In `@internal/utility/split.go`:
- Around line 24-27: Update the comments around keywordsSplitRE and the related
split logic to describe only the current delimiters and nil semantics. Remove
Python file, line-number, migration-history, and divergence references while
preserving accurate documentation of the runtime behavior.
🪄 Autofix (Beta)
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
Run ID: 052b1f9d-b472-4f85-8db5-9d7a2abd0634
📒 Files selected for processing (39)
cmd/ragflow_server.gointernal/common/parser_config.gointernal/handler/dataset.gointernal/handler/pipeline.gointernal/handler/pipeline_test.gointernal/ingestion/pipeline/builtin_registry.gointernal/ingestion/pipeline/builtin_registry_test.gointernal/ingestion/pipeline/real_storage_integration_test.gointernal/ingestion/pipeline/template/ingestion_pipeline_audio.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_book.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_email.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_general.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_laws.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_manual.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_one.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_paper.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_picture.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_presentation.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_qa.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_resume.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_table.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_tag.jsoninternal/ingestion/pipeline/template_integration_test.gointernal/ingestion/service/execute_task_test.gointernal/ingestion/service/ingestion_service.gointernal/ingestion/task/chunk_process.gointernal/ingestion/task/pipeline_real_integration_test.gointernal/parser/parser/factory.gointernal/parser/parser/factory_test.gointernal/router/router.gointernal/service/dataset.gointernal/service/dataset_parser_test.gointernal/service/document.gointernal/utility/split.gointernal/utility/split_test.goweb/src/hooks/use-user-setting-request.tsxweb/src/locales/en.tsweb/src/services/knowledge-service.tsweb/src/utils/api.ts
💤 Files with no reviewable changes (3)
- internal/parser/parser/factory_test.go
- internal/parser/parser/factory.go
- internal/handler/dataset.go
🛑 Comments failed to post (13)
cmd/ragflow_server.go (1)
41-41: 🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash set -euo pipefail # Inspect worker semantics, other constructors, and existing configuration knobs. rg -nP --type=go -C5 \ 'func\s+NewIngestor\b|\bNewIngestor\s*\(' \ . rg -n -i -C3 \ 'ingest(ion|or).*(concurr|worker)|worker.*limit|max.*workers' \ --glob '*.{go,yaml,yml,toml,json}' \ .Repository: infiniflow/ragflow
Length of output: 50374
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== cmd/ragflow_server.go startup flags/context ==" sed -n '1,140p' cmd/ragflow_server.go echo sed -n '450,510p' cmd/ragflow_server.go echo echo "== concurrency-related config/flags in repo ==" rg -n -i -C2 \ 'concurr|worker.*limit|maxConcurrency|max_concurrency|numcpu|NumCPU|ingestor' \ cmd internal --glob '*.{go,yaml,yml,toml,json}' echo echo "== ingestion service constructor and worker pool ==" sed -n '1,120p' internal/ingestion/service/ingestion_service.go sed -n '255,280p' internal/ingestion/service/ingestion_service.goRepository: infiniflow/ragflow
Length of output: 50375
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== server args and ingestor startup ==" sed -n '1,120p' cmd/ragflow_server.go printf '\n---\n' sed -n '470,500p' cmd/ragflow_server.go echo echo "== ingestion service worker sizing ==" sed -n '1,110p' internal/ingestion/service/ingestion_service.go printf '\n---\n' sed -n '255,275p' internal/ingestion/service/ingestion_service.go echo echo "== repo-wide config knobs related to worker counts ==" rg -n -i -C2 \ 'maxConcurrent|max_concurrent|workerCount|worker_count|concurrency|NumCPU|runtime.NumCPU|ingestor' \ cmd internal configs . \ --glob '*.{go,yaml,yml,toml,json}' \ --max-count 120Repository: infiniflow/ragflow
Length of output: 50375
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== ingestor-related flags/options in cmd/ragflow_server.go ==" rg -n -C2 --fixed-strings \ '--ingestor' \ cmd/ragflow_server.go echo rg -n -C2 -i \ 'worker|concurr|NumCPU|maxConcurrency' \ cmd/ragflow_server.go echo echo "== ingestor config fields in server config ==" rg -n -C2 -i \ 'ingestor|worker|concurr|NumCPU|maxConcurrent' \ internal/server internal/config cmd \ --glob '*.{go,yaml,yml,toml,json}' \ --max-count 80Repository: infiniflow/ragflow
Length of output: 655
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== cmd/ragflow_server.go: ingestor mode and startup ==" sed -n '1,120p' cmd/ragflow_server.go printf '\n---\n' sed -n '180,210p' cmd/ragflow_server.go printf '\n---\n' sed -n '484,500p' cmd/ragflow_server.go echo echo "== concurrency-related config fields in server/config packages ==" rg -n -i -C2 \ 'maxConcurrency|max_concurrent|concurr|worker|NumCPU|ingestor' \ internal/server internal/config cmd \ --glob '*.{go,yaml,yml,toml,json}' \ --max-count 80 echo echo "== ingestor constructor and worker pool ==" sed -n '42,107p' internal/ingestion/service/ingestion_service.go printf '\n---\n' sed -n '260,268p' internal/ingestion/service/ingestion_service.goRepository: infiniflow/ragflow
Length of output: 13088
Make ingestor concurrency configurable
cmd/ragflow_server.go:492hard-codesruntime.NumCPU()even thoughNewIngestoralready acceptsmaxConcurrency. Add a dedicated setting/flag with a conservative default and a cap instead of scaling worker count directly with host CPU count.🤖 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 `@cmd/ragflow_server.go` at line 41, Make the concurrency passed to NewIngestor configurable by adding a dedicated setting or flag with a conservative default and an upper bound, then use that value at the current runtime.NumCPU() call site instead of deriving workers directly from host CPU count. Retain NewIngestor’s maxConcurrency parameter and enforce the cap before constructing the ingestor.internal/common/parser_config.go (1)
110-112: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Finish the
naive→generalcanonicalization across dependent data.The registry exposes
generaland retainsnaiveonly as an alias, but both parser defaults and template metadata still use the legacy identity.
internal/common/parser_config.go#L110-L112: ensure canonicalgeneraland persisted aliasnaiveresolve to the same general-purpose defaults.internal/ingestion/pipeline/template/ingestion_pipeline_general.json#L445-L447: declaregeneral; rely on the registry alias for old rows.📍 Affects 2 files
internal/common/parser_config.go#L110-L112(this comment)internal/ingestion/pipeline/template/ingestion_pipeline_general.json#L445-L447🤖 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/common/parser_config.go` around lines 110 - 112, Update the defaults merge in internal/common/parser_config.go at lines 110-112 so both canonical general and persisted naive identifiers resolve to the same general-purpose defaults through the registry alias. Update internal/ingestion/pipeline/template/ingestion_pipeline_general.json at lines 445-447 to declare general instead of naive, relying on the registry alias for legacy rows.internal/handler/pipeline.go (2)
42-52: 🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
Treat the built-in registry as a required startup dependency.
internal/handler/pipeline.go#L42-L52: return the registry initialization error from the constructor.internal/handler/pipeline.go#L60-L64: remove the successful empty-catalog fallback.internal/router/router.go#L160-L166: require the handler and register the route unconditionally.internal/service/dataset.go#L3057-L3060: use the initialized registry instead of translating initialization failures into client errors.As per coding guidelines, converge on one runtime path rather than retaining degraded compatibility paths.
📍 Affects 3 files
internal/handler/pipeline.go#L42-L52(this comment)internal/handler/pipeline.go#L60-L64internal/router/router.go#L160-L166internal/service/dataset.go#L3057-L3060🤖 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/handler/pipeline.go` around lines 42 - 52, Treat the built-in pipeline registry as required: change NewPipelineHandler in internal/handler/pipeline.go to return initialization errors, remove the empty-catalog fallback in its handler path, require successful handler construction and register the route unconditionally in internal/router/router.go, and have internal/service/dataset.go use the initialized registry directly instead of converting initialization failures into client errors.Source: Coding guidelines
66-71: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Reject unsupported pipeline types instead of ignoring them.
Every
?type=...value currently returns builtins. Accept only empty/builtin, or return a data error for unsupported values.As per coding guidelines, remove speculative dual-track migration branches until an external contract requires them.
🤖 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/handler/pipeline.go` around lines 66 - 71, Update the pipeline type handling around pipelineType and the registry listing so empty or "builtin" requests continue returning h.registry.List(), while any other value returns a data error through the existing common response mechanism. Remove the speculative comment and unused-value suppression rather than retaining migration-oriented branches.Source: Coding guidelines
internal/ingestion/pipeline/builtin_registry.go (1)
159-160: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Deep-copy the DSL before returning it.
This only copies the map header. Any caller modifying
tpl.DSLor its nested values mutates the process-wide registry and changes subsequent ingestion executions. Return an recursively cloned JSON map and add an isolation test.🤖 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/ingestion/pipeline/builtin_registry.go` around lines 159 - 160, Update the registry return path around the visible template copy to recursively deep-clone tpl.DSL, including nested maps and slices, before returning the template so callers cannot mutate the process-wide registry. Preserve the existing lookup result behavior and add a test verifying mutations to the returned DSL do not affect subsequent registry retrievals.internal/ingestion/pipeline/template/ingestion_pipeline_laws.json (1)
160-160: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash rg -n -F '[\\((][0-9]{,2}[\\))]' internal/ingestion/pipeline/template rg -n -C4 'regexp\.(Compile|MustCompile)' internal/ingestionRepository: infiniflow/ragflow
Length of output: 16089
Replace the invalid
{,2}quantifier. Go’s regexp syntax requires a lower bound, so these patterns won’t compile as written. Use{1,2}in all matching template files:
internal/ingestion/pipeline/template/ingestion_pipeline_book.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_laws.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_paper.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_manual.json📍 Affects 2 files
internal/ingestion/pipeline/template/ingestion_pipeline_laws.json#L160-L160(this comment)internal/ingestion/pipeline/template/ingestion_pipeline_laws.json#L405-L405internal/ingestion/pipeline/template/ingestion_pipeline_manual.json#L121-L121internal/ingestion/pipeline/template/ingestion_pipeline_manual.json#L344-L344🤖 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/ingestion/pipeline/template/ingestion_pipeline_laws.json` at line 160, Replace the invalid `{,2}` quantifier with `{1,2}` in all affected matching templates: internal/ingestion/pipeline/template/ingestion_pipeline_laws.json at lines 160-160 and 405-405, internal/ingestion/pipeline/template/ingestion_pipeline_manual.json at lines 121-121 and 344-344, and the corresponding patterns in internal/ingestion/pipeline/template/ingestion_pipeline_book.json and internal/ingestion/pipeline/template/ingestion_pipeline_paper.json.internal/ingestion/pipeline/template/ingestion_pipeline_paper.json (1)
108-108: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash # Locate the TitleChunker implementation and its regex compilation path. rg -n -C4 --type go \ '\bTitleChunker\b|regexp\.(Compile|MustCompile)\s*\(' \ internal/ingestionRepository: infiniflow/ragflow
Length of output: 36242
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== template snippet ==" nl -ba internal/ingestion/pipeline/template/ingestion_pipeline_paper.json | sed -n '96,116p' echo echo "== template consumers ==" rg -n 'ingestion_pipeline_paper\.json|TitleChunker|regexp\.Compile\(' internal/ingestion -g '!**/*_test.go' echo echo "== Go regexp repetition syntax docs from local toolchain (if available) ==" python3 - <<'PY' import os, re, subprocess, sys # Print the stdlib doc excerpt if source is available locally. paths = [ os.path.expandvars("$GOROOT/src/regexp/syntax/doc.go"), ] for p in paths: p = os.path.expandvars(p) if os.path.exists(p): print(f"[{p}]") with open(p, "r", encoding="utf-8") as f: for i, line in enumerate(f, 1): if 140 <= i <= 190: sys.stdout.write(line) break else: print("GOROOT regexp/syntax/doc.go not found") PYRepository: infiniflow/ragflow
Length of output: 219
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== runtime probe for Go regexp syntax ==" python3 - <<'PY' import subprocess, textwrap, tempfile, os, json, sys code = r''' package main import ( "fmt" "regexp" ) func main() { patterns := []string{`[0-9]{,2}`, `[0-9]{1,2}`} for _, p := range patterns { re, err := regexp.Compile(p) if err != nil { fmt.Printf("%s => ERROR: %v\n", p, err) continue } fmt.Printf("%s => OK: %v\n", p, re.MatchString("7")) } } ''' with tempfile.TemporaryDirectory() as d: path = os.path.join(d, "main.go") open(path, "w", encoding="utf-8").write(code) # read-only compile/run probe; no repo code is executed. res = subprocess.run(["go", "run", path], text=True, capture_output=True) print("returncode:", res.returncode) print(res.stdout) print(res.stderr, file=sys.stderr) PYRepository: infiniflow/ragflow
Length of output: 259
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== template snippet ==" sed -n '100,112p' internal/ingestion/pipeline/template/ingestion_pipeline_paper.json echo echo "== nearby title regex patterns in Go code ==" sed -n '190,215p' internal/ingestion/component/chunker/title.go echo echo "== Go regexp behavior probe ==" python3 - <<'PY' import subprocess, tempfile, os, textwrap, sys code = r''' package main import ( "fmt" "regexp" ) func main() { p := `[\\((][0-9]{,2}[\\))]` re := regexp.MustCompile(p) tests := []string{"(7)", "(77)", "(777)", "()", "(a)", "(7)", "(77)", "(777)"} fmt.Println("pattern:", p) for _, s := range tests { fmt.Printf("%q => %v\n", s, re.MatchString(s)) } } ''' with tempfile.TemporaryDirectory() as d: path = os.path.join(d, "main.go") with open(path, "w", encoding="utf-8") as f: f.write(code) r = subprocess.run(["go", "run", path], text=True, capture_output=True) print("returncode:", r.returncode) print(r.stdout) if r.stderr: print(r.stderr, file=sys.stderr) PYRepository: infiniflow/ragflow
Length of output: 1862
🏁 Script executed:
#!/bin/bash set -euo pipefail python3 - <<'PY' from pathlib import Path p = Path('internal/ingestion/pipeline/template/ingestion_pipeline_paper.json') text = p.read_text(encoding='utf-8').splitlines() for i in range(102, 111): print(f"{i+1}: {text[i]}") PYRepository: infiniflow/ragflow
Length of output: 669
🏁 Script executed:
#!/bin/bash set -euo pipefail python3 - <<'PY' import subprocess, tempfile, os, sys, textwrap code = r''' package main import ( "fmt" "regexp" ) func main() { p := `[\\((][0-9]{,2}[\\))]` re := regexp.MustCompile(p) tests := []string{ "(7)", "(77)", "(,2)", "({,2})", "(12)", "(12)", "(a)", "({,2]", } for _, s := range tests { fmt.Printf("%q => %v\n", s, re.MatchString(s)) } } ''' with tempfile.TemporaryDirectory() as d: path = os.path.join(d, "main.go") with open(path, "w", encoding="utf-8") as f: f.write(code) r = subprocess.run(["go", "run", path], text=True, capture_output=True) print("returncode:", r.returncode) print(r.stdout) if r.stderr: print(r.stderr, file=sys.stderr) PYRepository: infiniflow/ragflow
Length of output: 300
🏁 Script executed:
#!/bin/bash set -euo pipefail python3 - <<'PY' import json, subprocess, tempfile, os, sys json_pattern = r'"[\\((][0-9]{,2}[\\))]"' pattern = json.loads(json_pattern) print("decoded pattern:", pattern) code = f''' package main import ( "fmt" "regexp" ) func main() {{ p := {pattern!r} re, err := regexp.Compile(p) fmt.Println("compile_err:", err) tests := []string{{"(7)", "(77)", "(777)", "()", "(a)", "(7)", "(77)", "(777)"}} for _, s := range tests {{ fmt.Printf("%q => %v\n", s, re.MatchString(s)) }} }} ''' with tempfile.TemporaryDirectory() as d: path = os.path.join(d, "main.go") with open(path, "w", encoding="utf-8") as f: f.write(code) r = subprocess.run(["go", "run", path], text=True, capture_output=True) print("returncode:", r.returncode) print(r.stdout) if r.stderr: print(r.stderr, file=sys.stderr) PYRepository: infiniflow/ragflow
Length of output: 516
🏁 Script executed:
#!/bin/bash set -euo pipefail python3 - <<'PY' import subprocess, tempfile, os, textwrap, sys code = r''' package main import ( "fmt" "regexp" ) func probe(label, pattern string, tests []string) { re, err := regexp.Compile(pattern) fmt.Printf("%s compile_err: %v\n", label, err) for _, s := range tests { fmt.Printf("%s %q => %v\n", label, s, re.MatchString(s)) } } func main() { tests := []string{"(7)", "(77)", "(777)", "()", "(a)", "(7)", "(77)", "(777)", "(7{,2})"} probe("bad", `[\((][0-9]{,2}[\))]`, tests) probe("good", `[\((][0-9]{1,2}[\))]`, tests) } ''' with tempfile.TemporaryDirectory() as d: path = os.path.join(d, "main.go") with open(path, "w", encoding="utf-8") as f: f.write(code) r = subprocess.run(["go", "run", path], text=True, capture_output=True) print("returncode:", r.returncode) print(r.stdout) if r.stderr: print(r.stderr, file=sys.stderr) PYRepository: infiniflow/ragflow
Length of output: 582
🏁 Script executed:
#!/bin/bash set -euo pipefail python3 - <<'PY' import os from pathlib import Path p = Path(os.environ.get("GOROOT", "/usr/local/go")) / "src/regexp/syntax/doc.go" if p.exists(): text = p.read_text(encoding="utf-8").splitlines() for i, line in enumerate(text, 1): if 55 <= i <= 90: print(f"{i}: {line}") else: print(f"missing: {p}") PYRepository: infiniflow/ragflow
Length of output: 1778
Replace
[0-9]{,2}with[0-9]{1,2}internal/ingestion/pipeline/template/ingestion_pipeline_paper.json:108— the current pattern matches a literal{,2}sequence, so it won’t catch one- or two-digit markers.🤖 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/ingestion/pipeline/template/ingestion_pipeline_paper.json` at line 108, Update the marker regex in the ingestion pipeline template to use the valid one-to-two-digit quantifier `[0-9]{1,2}` instead of `[0-9]{,2}`, preserving the surrounding parenthesis matching.internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json (1)
8-11: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Remove the unsupported Keynote claim.
The parser accepts only
pptx, andppt, so the catalog currently advertises a format this template cannot ingest. Remove Keynote from all three descriptions unless.keysupport is added.🤖 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/ingestion/pipeline/template/ingestion_pipeline_presentation.json` around lines 8 - 11, Update the English, German, and Chinese description values in the ingestion pipeline presentation template to remove the unsupported Keynote format claim. Keep the existing descriptions and supported PowerPoint/PDF-related wording unchanged, without adding .key support.internal/service/dataset_parser_test.go (1)
24-31: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Cover the complete canonical pipeline catalog.
The test claims to validate every builtin ID but omits
laws,manual,one,paper,picture,presentation, andresume.Proposed update
- for _, id := range []string{"general", "book", "audio", "qa", "table", "tag"} { + for _, id := range []string{ + "general", "audio", "book", "email", "laws", "manual", "one", + "paper", "picture", "presentation", "qa", "resume", "table", "tag", + } {📝 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.// TestValidateParserID_AcceptsRegistryRefs verifies that every // canonical builtin pipeline id passes validation. func TestValidateParserID_AcceptsRegistryRefs(t *testing.T) { for _, id := range []string{ "general", "audio", "book", "email", "laws", "manual", "one", "paper", "picture", "presentation", "qa", "resume", "table", "tag", } { if err := validateParserID(id); err != nil { t.Errorf("validateParserID(%q) = %v, want nil", id, err) } } }🤖 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/dataset_parser_test.go` around lines 24 - 31, The TestValidateParserID_AcceptsRegistryRefs test does not cover the complete canonical pipeline catalog. Extend its table of IDs to include email, laws, manual, one, paper, picture, presentation, and resume while preserving the existing validation assertions.internal/service/dataset.go (1)
3052-3064: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Keep legacy aliases at the read boundary, not in new-write validation.
internal/service/dataset.go#L3052-L3064: resolve aliases to canonical IDs and return the canonical value for persistence.internal/service/dataset_parser_test.go#L34-L41: movenaivecompatibility coverage to loading existing pipeline data.As per coding guidelines, remove compatibility-only surfaces and tests while preserving externally required existing-data behavior.
📍 Affects 2 files
internal/service/dataset.go#L3052-L3064(this comment)internal/service/dataset_parser_test.go#L34-L41🤖 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/dataset.go` around lines 3052 - 3064, Update validateParserID in internal/service/dataset.go to resolve accepted legacy aliases to their canonical pipeline IDs and return that canonical value for persistence, rather than only validating the input; update all callers as needed to use the returned ID. In internal/service/dataset_parser_test.go lines 34-41, remove new-write compatibility coverage for “naive” and move it to loading existing pipeline data, preserving legacy read behavior without retaining compatibility-only validation surfaces.Source: Coding guidelines
internal/utility/split.go (1)
68-72: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Handle CRLF question separators.
strings.Split(s, "\n")turns"Q1\r\nQ2"into["Q1\r", "Q2"], polluting indexedquestion_kwdvalues. Split on both newline characters and add a CRLF test.Proposed fix
func SplitQuestions(s string) []string { if s == "" { return nil } - return nonEmpty(strings.Split(s, "\n")) + return strings.FieldsFunc(s, func(r rune) bool { + return r == '\r' || r == '\n' + }) }📝 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.func SplitQuestions(s string) []string { if s == "" { return nil } return strings.FieldsFunc(s, func(r rune) bool { return r == '\r' || r == '\n' })🤖 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/utility/split.go` around lines 68 - 72, Update SplitQuestions to treat CRLF and LF as equivalent question separators, ensuring carriage returns are not retained in returned question strings; add a test covering input such as “Q1\r\nQ2” and verify clean indexed values.web/src/hooks/use-user-setting-request.tsx (1)
108-115: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Use a
PipelineKeysquery-key factory.The inline
['listPipelines']key bypasses the required domain factory and can diverge from future invalidations.Proposed fix
+const PipelineKeys = { + list: () => ['pipelines', 'list'] as const, +}; + const { data: pipelineListData } = useQuery({ - queryKey: ['listPipelines'], + queryKey: PipelineKeys.list(),As per coding guidelines, “Never write raw React Query queryKey arrays inline; use a domain query-key factory returning as const tuples.”
📝 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.const PipelineKeys = { list: () => ['pipelines', 'list'] as const, }; const { data: pipelineListData } = useQuery({ queryKey: PipelineKeys.list(), queryFn: async () => { const { data } = await kbService.listPipelines(); return data; }, staleTime: Infinity, });🤖 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 `@web/src/hooks/use-user-setting-request.tsx` around lines 108 - 115, Replace the inline queryKey array in the useQuery call with the domain PipelineKeys query-key factory, using its list-pipelines key and preserving the existing query behavior. Ensure the factory returns the required readonly tuple and reuse the same key for future invalidation consistency.Source: Coding guidelines
web/src/services/knowledge-service.ts (1)
70-73: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Route this endpoint through
registerNextServer.This method is currently added to the map backed by
registerServer(..., request)at Line 80. Register it throughregisterNextServerand@/utils/next-requestinstead.As per coding guidelines, “Register HTTP endpoints in the service layer via registerNextServer, routing requests through
@/utils/next-request.”🤖 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 `@web/src/services/knowledge-service.ts` around lines 70 - 73, Update the listPipelines registration to use registerNextServer with the request helper from `@/utils/next-request` instead of the registerServer(..., request) mapping. Preserve the endpoint’s existing URL and GET method configuration.Source: Coding guidelines
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/utility/best_effort.go`:
- Around line 30-38: Update BestEffort to recover panics raised by f, report the
recovered panic through common.Error with the label, and return without
propagating it so cleanup failures remain non-aborting. Preserve the existing
nil-function handling and ordinary error reporting.
🪄 Autofix (Beta)
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
Run ID: 0ab1b438-1906-4a37-a60b-ffb3b9a26a4c
📒 Files selected for processing (5)
internal/ingestion/pipeline/pipeline.gointernal/ingestion/service/ingestion_service.gointernal/service/dataset.gointernal/utility/best_effort.gointernal/utility/best_effort_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
- internal/ingestion/pipeline/pipeline.go
- internal/ingestion/service/ingestion_service.go
| func BestEffort(label string, f func() error) { | ||
| if f == nil { | ||
| common.Error(fmt.Sprintf("best-effort %s: nil function", label), fmt.Errorf("nil function")) | ||
| return | ||
| } | ||
| if err := f(); err != nil { | ||
| common.Error(fmt.Sprintf("best-effort %s failed: %v", label, err), err) | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Check if common.Error expects an error or zap.Field arguments
ast-grep outline internal/common --items all --type function --match 'Error'Repository: infiniflow/ragflow
Length of output: 295
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== best_effort.go ==\n'
cat -n internal/utility/best_effort.go
printf '\n== logger.go (outline) ==\n'
ast-grep outline internal/common/logger.go --items all
printf '\n== logger.go (Error definition) ==\n'
rg -n "func Error\\b|type .*Logger|Error\\(" internal/common/logger.go internal/common -g '!**/*_test.go' -A 6 -B 3Repository: infiniflow/ragflow
Length of output: 8825
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo '--- internal/common/logger.go ---'
sed -n '1,220p' internal/common/logger.go | cat -n
echo '--- internal/utility/best_effort.go ---'
sed -n '1,120p' internal/utility/best_effort.go | cat -nRepository: infiniflow/ragflow
Length of output: 9309
🏁 Script executed:
#!/bin/bash
set -euo pipefail
grep -nE '^(func (Error|Warn|Info|Debug)|type .*Logger)' internal/common/logger.goRepository: infiniflow/ragflow
Length of output: 365
🌐 Web query:
"site:github.com infiniflow/ragflow internal/common/logger.go func Error zap.Field"
💡 Result:
In the RAGFlow codebase, the Error function defined in internal/logger/logger.go (and exposed via internal/common/logger.go) does not accept variadic zap.Field arguments [1]. Instead, it is specifically designed to accept a message string and an error object [1]. The signature of the Error function is as follows: func Error(msg string, err error) { if Logger == nil { return } Logger.Error(msg, zap.Error(err)) } As shown above, the function internally uses zap.Error(err) to convert the provided error into a zap.Field before passing it to the underlying logger instance [1]. Because of this design, you cannot pass arbitrary zap.Field slice to common.Error. If you need to log additional fields alongside an error, you would typically use common.Warn or other logging functions that support variadic zap.Field arguments (e.g., func Warn(msg string, fields ...zap.Field)), or you would need to adjust the logging implementation to support your requirements [1][2].
Citations:
- 1: https://github.com/infiniflow/ragflow/blob/384fa6fc/internal/logger/logger.go
- 2: https://github.com/infiniflow/ragflow/blob/3f805a64/internal/handler/error.go
Recover panics in BestEffort
f can still panic and escape this helper, which breaks the “never panics” / “must not abort the task” contract. Wrap the call with recover so cleanup failures stay best-effort.
🤖 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/utility/best_effort.go` around lines 30 - 38, Update BestEffort to
recover panics raised by f, report the recovered panic through common.Error with
the label, and return without propagating it so cleanup failures remain
non-aborting. Preserve the existing nil-function handling and ordinary error
reporting.
5b05969 to
f37fbcd
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/service/dataset.go (1)
3138-3166: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winAvoid double
DefaultRegistry()lookup on the invalid-parser_id path.
validateParserIDfetches the registry, and on failure callsparserIDError(), which fetches the registry again. Thread the already-resolvedregistryinto the error builder instead.♻️ Proposed refactor
func validateParserID(chunkMethod string) error { registry, err := pipelinepkg.DefaultRegistry() if err != nil || registry == nil { return errors.New("parser_id validation unavailable: builtin pipeline registry not loaded") } if registry.IsValid(chunkMethod) { return nil } - return parserIDError() + return parserIDErrorFromRegistry(registry) } -func parserIDError() error { - registry, err := pipelinepkg.DefaultRegistry() - if err != nil || registry == nil { - return errors.New("invalid parser_id") - } +func parserIDError() error { + registry, err := pipelinepkg.DefaultRegistry() + if err != nil || registry == nil { + return errors.New("invalid parser_id") + } + return parserIDErrorFromRegistry(registry) +} + +func parserIDErrorFromRegistry(registry *pipelinepkg.Registry) error { refs := registry.Refs() switch len(refs) { case 0: return errors.New("invalid parser_id") case 1: return fmt.Errorf("Input should be '%s'", refs[0]) default: return fmt.Errorf("Input should be %s or '%s'", quoteList(refs[:len(refs)-1]), refs[len(refs)-1]) } }🤖 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/dataset.go` around lines 3138 - 3166, The invalid path in validateParserID performs a second pipeline registry lookup through parserIDError. Change parserIDError to accept the already-resolved registry from validateParserID, remove its DefaultRegistry lookup and fallback handling, and use the passed registry to build the existing validation message.
🤖 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.
Nitpick comments:
In `@internal/service/dataset.go`:
- Around line 3138-3166: The invalid path in validateParserID performs a second
pipeline registry lookup through parserIDError. Change parserIDError to accept
the already-resolved registry from validateParserID, remove its DefaultRegistry
lookup and fallback handling, and use the passed registry to build the existing
validation message.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 2a22b7cc-8b35-46e8-8000-10d01709b638
📒 Files selected for processing (61)
cmd/ragflow_server.gointernal/common/parser_config.gointernal/handler/pipeline.gointernal/handler/pipeline_test.gointernal/ingestion/component/tokenizer.gointernal/ingestion/component/tokenizer_test.gointernal/ingestion/component/tokenizer_unit_test.gointernal/ingestion/pipeline/builtin_registry.gointernal/ingestion/pipeline/builtin_registry_test.gointernal/ingestion/pipeline/pipeline.gointernal/ingestion/pipeline/real_storage_integration_test.gointernal/ingestion/pipeline/template/ingestion_pipeline_audio.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_book.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_email.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_general.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_laws.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_manual.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_one.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_paper.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_picture.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_presentation.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_qa.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_resume.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_table.jsoninternal/ingestion/pipeline/template/ingestion_pipeline_tag.jsoninternal/ingestion/pipeline/template_integration_test.gointernal/ingestion/service/doc_state.gointernal/ingestion/service/execute_task_ack_test.gointernal/ingestion/service/execute_task_test.gointernal/ingestion/service/ingestion_service.gointernal/ingestion/service/ingestor_lifecycle_test.gointernal/ingestion/task/chunk_index_writer.gointernal/ingestion/task/chunk_process.gointernal/ingestion/task/chunk_process_test.gointernal/ingestion/task/chunk_utils.gointernal/ingestion/task/chunk_utils_test.gointernal/ingestion/task/embedder.gointernal/ingestion/task/golden_compare.gointernal/ingestion/task/golden_compare_test.gointernal/ingestion/task/pipeline_executor.gointernal/ingestion/task/pipeline_executor_defaults.gointernal/ingestion/task/pipeline_executor_test.gointernal/ingestion/task/pipeline_real_integration_test.gointernal/ingestion/task/task_context.gointernal/ingestion/task/tool/compare_pipeline_golden.gointernal/parser/parser/factory.gointernal/parser/parser/factory_test.gointernal/router/router.gointernal/service/dataset.gointernal/service/dataset_parser_test.gointernal/service/document.gointernal/service/ingestion_task_service.gointernal/service/ingestion_task_service_test.gointernal/utility/best_effort.gointernal/utility/best_effort_test.gointernal/utility/split.gointernal/utility/split_test.goweb/src/hooks/use-user-setting-request.tsxweb/src/locales/en.tsweb/src/services/knowledge-service.tsweb/src/utils/api.ts
💤 Files with no reviewable changes (2)
- internal/parser/parser/factory_test.go
- internal/parser/parser/factory.go
🚧 Files skipped from review as they are similar to previous changes (51)
- web/src/locales/en.ts
- internal/ingestion/task/golden_compare_test.go
- internal/utility/best_effort.go
- web/src/utils/api.ts
- internal/ingestion/task/embedder.go
- internal/ingestion/task/task_context.go
- internal/ingestion/service/doc_state.go
- web/src/services/knowledge-service.ts
- internal/handler/pipeline.go
- internal/ingestion/task/tool/compare_pipeline_golden.go
- internal/utility/best_effort_test.go
- internal/ingestion/pipeline/template/ingestion_pipeline_laws.json
- internal/service/dataset_parser_test.go
- internal/ingestion/component/tokenizer.go
- internal/utility/split_test.go
- internal/ingestion/pipeline/template/ingestion_pipeline_one.json
- internal/ingestion/service/execute_task_ack_test.go
- internal/ingestion/pipeline/template/ingestion_pipeline_presentation.json
- web/src/hooks/use-user-setting-request.tsx
- internal/ingestion/task/chunk_index_writer.go
- internal/service/ingestion_task_service_test.go
- internal/utility/split.go
- internal/ingestion/pipeline/pipeline.go
- internal/router/router.go
- internal/ingestion/pipeline/template/ingestion_pipeline_tag.json
- internal/common/parser_config.go
- internal/ingestion/pipeline/template/ingestion_pipeline_audio.json
- internal/ingestion/pipeline/builtin_registry.go
- internal/ingestion/pipeline/template/ingestion_pipeline_general.json
- internal/ingestion/pipeline/template/ingestion_pipeline_picture.json
- internal/ingestion/pipeline/template/ingestion_pipeline_resume.json
- internal/ingestion/pipeline/template/ingestion_pipeline_email.json
- internal/ingestion/pipeline/template/ingestion_pipeline_manual.json
- internal/ingestion/pipeline/template/ingestion_pipeline_qa.json
- internal/handler/pipeline_test.go
- internal/service/document.go
- internal/ingestion/pipeline/builtin_registry_test.go
- internal/ingestion/task/chunk_utils.go
- internal/ingestion/pipeline/template/ingestion_pipeline_table.json
- internal/ingestion/pipeline/template/ingestion_pipeline_book.json
- internal/ingestion/service/ingestor_lifecycle_test.go
- cmd/ragflow_server.go
- internal/service/ingestion_task_service.go
- internal/ingestion/pipeline/template_integration_test.go
- internal/ingestion/component/tokenizer_unit_test.go
- internal/ingestion/pipeline/template/ingestion_pipeline_paper.json
- internal/ingestion/task/chunk_process.go
- internal/ingestion/service/ingestion_service.go
- internal/ingestion/task/chunk_process_test.go
- internal/ingestion/component/tokenizer_test.go
- internal/ingestion/task/pipeline_executor.go
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
web/src/hooks/use-user-setting-request.tsx (1)
106-115: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winUse a domain query-key factory for React Query keys.
As per coding guidelines, never write raw React Query
queryKeyarrays inline. Use a domain query-key factory returningas consttuples in the same file.♻️ Proposed refactor
Define a query-key factory at the top of the file:
export const UserSettingKeys = { listPipelines: () => ['listPipelines'] as const, };And update the hook:
const { data: pipelineListData } = useQuery({ - queryKey: ['listPipelines'], + queryKey: UserSettingKeys.listPipelines(), queryFn: async () => { const { data } = await kbService.listPipelines();🤖 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 `@web/src/hooks/use-user-setting-request.tsx` around lines 106 - 115, Replace the inline queryKey array in the useQuery call with a UserSettingKeys domain factory defined near the top of the file. Add listPipelines() returning the ['listPipelines'] tuple with as const, then reference UserSettingKeys.listPipelines() in the query configuration.Source: Coding guidelines
🤖 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.
Outside diff comments:
In `@web/src/hooks/use-user-setting-request.tsx`:
- Around line 106-115: Replace the inline queryKey array in the useQuery call
with a UserSettingKeys domain factory defined near the top of the file. Add
listPipelines() returning the ['listPipelines'] tuple with as const, then
reference UserSettingKeys.listPipelines() in the query configuration.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9985183c-935b-44ed-a54e-fd6dd24502f4
📒 Files selected for processing (7)
internal/handler/pipeline_test.gointernal/ingestion/pipeline/builtin_registry.gointernal/ingestion/pipeline/builtin_registry_test.gointernal/router/router.gotest/testcases/restful_api/test_datasets.pyweb/src/components/chunk-method-dialog/hooks.tsweb/src/hooks/use-user-setting-request.tsx
🚧 Files skipped from review as they are similar to previous changes (3)
- internal/handler/pipeline_test.go
- internal/ingestion/pipeline/builtin_registry_test.go
- internal/ingestion/pipeline/builtin_registry.go
|
@yuzhichang @JinHai-CN @yingfeng Pls help to review. |
| "github.com/gin-gonic/gin" | ||
| "go.uber.org/zap" | ||
|
|
||
| "ragflow/internal/common" |
| defer tokenizer.Close() | ||
|
|
||
| ingestor := ingestion.NewIngestor(*args.name, 2, []string{"pdf", "docx", "txt"}) | ||
| ingestor := ingestion.NewIngestor(*args.name, int32(runtime.NumCPU()), []string{"pdf", "docx", "txt"}) |
There was a problem hiding this comment.
- concurrency configure-able
- doc types?
Both backends now serve GET /api/v1/language:
- Go backend → {"language": "go"}
- Python backend → {"language": "python"}
The front end calls this endpoint once at runtime and caches the result,
then uses it to choose the matching parser-list code path:
- Go backend → fetch the pipeline catalog dynamically from /api/v1/pipelines
(the approach from PR infiniflow#16873, which requires the Go backend endpoint)
- Python backend → use the hardcoded defaultParsers list and
tenant-level parser_ids (the original approach)
New frontend utility:
- web/src/utils/backend-runtime.ts — lightweight fetch-once module
(same pattern as enterprise billingStatus.ts)
Co-Authored-By: Claude <[email protected]>
Both backends now serve GET /api/v1/language:
- Go backend → {"language": "go"}
- Python backend → {"language": "python"}
The front end calls this endpoint once at runtime and caches the result,
then uses it to choose the matching parser-list code path:
- Go backend → fetch the pipeline catalog dynamically from /api/v1/pipelines
(the approach from PR infiniflow#16873, which requires the Go backend endpoint)
- Python backend → use the hardcoded defaultParsers list and
tenant-level parser_ids (the original approach)
New frontend utility:
- web/src/utils/backend-runtime.ts — lightweight fetch-once module
(same pattern as enterprise billingStatus.ts)
Co-Authored-By: Claude <[email protected]>
Summary