Skip to content

fix: store source key only in pipeline_operation_log.source_from - #18239

Merged
wangq8 merged 2 commits into
infiniflow:mainfrom
euvre:fix/pipeline-log-source-from
Aug 20, 2026
Merged

wangq8 merged 2 commits into
infiniflow:mainfrom
euvre:fix/pipeline-log-source-from

Conversation

@euvre

@euvre euvre commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

KB logs page (Dataset -> Logs) shows a generic computer-upload icon in the Source column for files synced from a datasource (e.g. RSS) instead of the datasource-specific icon.

Root cause: for connector-synced documents, document.source_type is stored as <source>/<connector_id> (e.g. rss/<connector_id>). The Go ingestion backend (recordPipelineLog in internal/ingestion/task/pipeline_executor.go) copied this verbatim into pipeline_operation_log.source_from. The frontend (web/src/pages/dataset/dataset-overview/overview-table.tsx) maps source_from to a datasource icon by exact key lookup (DataSourceKey.RSS === 'rss'), so the connector-qualified value missed the lookup and fell back to the generic icon.

Fix: strip the connector id and store only the bare source key in source_from (strings.Cut(sourceType, "/")).

Verified live: inserted two pipeline_operation_log rows into a test KB, one with source_from='rss/<connector_id>' (shows generic computer icon) and one with source_from='rss' (shows the RSS icon).

Type of change

  • Bug Fix (non-breaking change which fixes an issue)

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. labels Aug 13, 2026
@coderabbitai

coderabbitai Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8664b8b8-9a25-4580-9edf-3e816568e167

📥 Commits

Reviewing files that changed from the base of the PR and between 7ed91cd and dc3a353.

📒 Files selected for processing (1)
  • internal/ingestion/task/pipeline_executor_test.go

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

The change expands pipeline log tests. It covers source normalization and verifies that recordPipelineLog uses the source from the persisted document instead of the task context.

Changes

Pipeline log source normalization

Layer / File(s) Summary
Normalize and validate SourceFrom
internal/ingestion/task/pipeline_executor_test.go
The test database migrates entity.Document. Table-driven tests verify connector IDs are removed while plain and empty source values remain unchanged.
Use the reloaded document source
internal/ingestion/task/pipeline_executor_test.go
An integration test persists a connector source, supplies a conflicting task-context source, and verifies pipeline logging uses the persisted document value.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to dc3a3

The change is localized to source-key handling and no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: xugangqiang, b sua436

Poem

A rabbit checks the source in the log,
Then reloads the document from its log.
Connector IDs hop away,
Plain values choose to stay.
Conflicting task fields lose the race—
Tests confirm the stored source place.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title describes the source_from normalization behavior covered by the tests, although it does not explicitly mention that this PR adds test coverage.
Description check ✅ Passed The description clearly explains the problem, root cause, fix, validation, and change type, but uses a different heading from the template.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@euvre
euvre requested a review from wangq8 August 18, 2026 04:36

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fix itself is correct — synced documents store source_type as <source>/<connector_id> (internal/service/sync_task_service.go), and strings.Cut(sourceType, "/") correctly recovers the bare source key so the KB logs page can match the datasource icon.

However, this PR currently shows mergeable: CONFLICTING against main. The same fix has already been merged via #18366 (commit 1ef4dddde, "fix: align Go ingestion progress and pipeline selection"), which strips the connector id in recordPipelineLog using strings.SplitN(sourceFrom, "/", 2).

Please rebase onto latest main and confirm whether this PR is still needed. If #18366 already covers the reported bug, this PR can be closed as superseded; otherwise update the change to align with the reloaded doc variable now used in recordPipelineLog.

The added test (TestRecordPipelineLog_SourceFrom) is good, but it will also need updating for the doc reload introduced in #18366.

Synced documents carry source_type as '<source>/<connector_id>'
(e.g. 'rss/<connector_id>'). The KB logs page maps source_from to a
datasource icon by exact key, so the connector-qualified value fell
back to the generic computer-upload icon. Strip the connector id and
store the bare source key (e.g. 'rss').
@euvre
euvre force-pushed the fix/pipeline-log-source-from branch from 0e99c52 to 7ed91cd Compare August 20, 2026 11:25
@coderabbitai

coderabbitai Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

recordPipelineLog reloads the persisted document and derives source_from
from that row. Seed a connector-qualified source_type in the test DB and
assert the log stores the bare source key from the reloaded doc, not the
stale task-context snapshot.
@euvre

euvre commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@wangq8 Thanks for the careful review — addressed each point:

1. Rebase / conflict. The branch is now based on the current main tip (4304a3b7c), so the CONFLICTING state is resolved.

2. Is the PR still needed? Confirmed: the production fix was merged via #18366 — recordPipelineLog on main now derives source_from from the reloaded doc and strips the connector id with strings.SplitN(sourceFrom, "/", 2) (internal/ingestion/task/pipeline_executor.go). Accordingly, this PR no longer contains any production-code change; its remaining value is test coverage only, which main does not have for this behavior.

3. Test updated for the doc reload. As you noted, the original TestRecordPipelineLog_SourceFrom only exercised the fallback path (db == nil, snapshot from taskCtx.Doc). Added TestRecordPipelineLog_SourceFromReloadedDoc: it seeds a document row with source_type = 'rss/connector-811' in the in-memory sqlite DB, deliberately sets a stale taskCtx.Doc.SourceType = 'local', and asserts the recorded log stores source_from = 'rss' — proving the value comes from the reloaded document, not the task-context snapshot. Also extended setupPipelineExecutorTestDB to auto-migrate entity.Document. Pushed as dc3a353da.

Verification. bash build.sh --test ./internal/ingestion/task/... passes; a focused run shows TestRecordPipelineLog_SourceFrom (3 subtests) and TestRecordPipelineLog_SourceFromReloadedDoc all PASS. Validation boundary: no end-to-end run against shared ragflow services was performed from this lane; the evidence is unit tests plus line-level comparison with the #18366 implementation on main.

Net: this PR is now a test-only change that locks in the source_from normalization behavior (connector-id stripping on both the reload path and the no-DB fallback path). If you judge the coverage unnecessary, feel free to close it as superseded by #18366.

@wangq8 wangq8 added the ci Continue Integration label Aug 20, 2026
@wangq8
wangq8 merged commit c87aa3b into infiniflow:main Aug 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants