Skip to content

fix(parser): use selected tenant SoMark and OpenDataLoader instances - #21112

Merged
yuzhichang merged 4 commits into
infiniflow:mainfrom
ZXLyyds100:fix/pdf-tenant-parser-models
Oct 20, 2026
Merged

yuzhichang merged 4 commits into
infiniflow:mainfrom
ZXLyyds100:fix/pdf-tenant-parser-models

Conversation

@ZXLyyds100

@ZXLyyds100 ZXLyyds100 commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Latest delivered head: 73917c62badf86c59fccf4664c9273b9a4696dd4 (October 20 conflict resolution and exact-head acceptance below).

Current acceptance — October 20, 2026

Addressed the maintainer's conflict request
by merging upstream f2b9d65ef1abd722c906d5fe6c791e0bd2935ed9 without rewriting
published history. The sole manual conflict was the Parser guide: both complete
MinerU controls and tenant SoMark/OpenDataLoader sections remain, with separate
valid JSON examples and upstream image/PaddleOCR documentation preserved.
The effective PR remains nine files; it contains no workflow/build/dependency
or approval-policy changes relative to the merged upstream.

  • Fresh hosted Linux CI on 73917c62badf86c59fccf4664c9273b9a4696dd4:
    sep-tests #20902
    completed successfully. Preflight, Go integration, Infinity and Elasticsearch
    jobs all executed successfully. Their actual Go unit, integration and both
    backend API test steps were verified, as was the dependency regression guard.
    ragflow_native_backend was skipped without steps, not executed or counted
    as native/inference coverage. These are workflow job/step results, not a claim
    that all repository packages, production inference or race tests ran.
  • Local merge acceptance: 14 merge/document/JSON/scope/format checks and all
    nine applicable normal pre-commit checks passed. Seven non-dispatch Go files
    are byte-identical to the previously tested feature head; the merged dispatcher
    retains all upstream code plus only the original tenant-dispatch insertion.
    Application/native/race suites were not rerun locally for this documentation
    conflict. Historical local test counts below retain their original revisions.
  • CodeRabbit reviewed this exact head and posted zero actionable comments.
    This automated result and earlier-head human reviews do not constitute
    current-head human/CODEOWNER approval.
  • No UI was changed by the conflict resolution. Existing before/after captures
    remain tied to their stated original revisions and synthetic fixture/native
    adaptation boundaries; they were not recaptured or relabeled.

Fixes #21027.

Initial reviewed head: b1b16e08d57f323162f9d9992fb87c395ae96ad0 (superseded by the latest delivered head).

Connect saved tenant OCR model references to the existing SoMark and
OpenDataLoader Go PDF parsers
. On current main, these references can reach the
generic vision path even though the intended parser already exists.

  • Resolve both tenant model IDs and model@instance@provider, using the same
    PDF selector precedence as the existing dispatch.
  • Look up the exact enrolled model/provider/instance through the existing
    DAOs. Reject foreign tenants, mismatched instances, disabled records and
    non-OCR models; never substitute the provider's first instance.
  • Read the selected instance's endpoint and credentials at execution time.
    Keep saved parser setup unchanged and do not borrow global credentials
    when the selected instance has an intentionally empty optional key.
  • Reuse the current parser implementations and SSRF-safe request owner.
    SoMark/OpenDataLoader do not have generic model drivers on main, so this
    does not introduce dummy drivers or a parallel parser protocol.
  • Preserve bare engine-name/setup/environment invocation. Selected-instance
    settings are runtime-only; non-secret SoMark model options can supply
    defaults, while explicit non-secret pipeline options take precedence.

No frontend, database schema, migration, dependency, workflow or builtin
template changes. This branch is independent of #21109 and #21111.
Existing SoMark polling/cancellation is unchanged; #21076 covers that separately.

Before / after evidence

The same standalone capture test was compiled against
543e16738b4883fcb7e70520e0b5849e7e18c9b7 and this implementation,
691a50a5ddfac05e9c5fd66ca422a09d9c3092c9. It invokes the exported production
Parser, actual builtin config cleaning and JSON reload, real SQLite DAOs, PDF
dispatch and existing parser code. No internal resolver/renderer/dispatcher/
parser function is replaced.

The OCR responses and tenant rows are explicitly labeled local fixtures.
These screenshots show a test evidence viewer, not RAGFlow product UI.
The viewer reads actual runtime captures rather than generating expected results.

Original source Fixed source
SoMark tenant ID fails before reaching OCR SoMark tenant ID uses only selected instance B
OpenDataLoader composite fails before reaching OCR OpenDataLoader composite uses only selected instance B

18-second recording
· all eight captures, screenshots, replay source and logs
· runtime comparison.

The four original captures fail without an OCR request. The four fixed captures
call only selected instance B with its fixture credential, preserve returned
structured text, and leave saved configuration unchanged. The recording switches
among those captures; it does not rerun Go on each click. All 216 VP8 frames were
independently decoded, and representative frames visually reviewed.
Media and replay files are on a separate fork-only branch, outside the code PR.

Validation and review

  • Reproduced all eight provider × selector-field × reference-form regressions
    against original source before implementation.
  • Final focused selection, complete related suites and race scenarios passed
    with -count=1 through unchanged build.sh.
    The related run passed 30 packages across
    ./internal/ingestion/... ./internal/parser/... ./internal/dao/...
    ./internal/common/... ./internal/utility/....
  • Tests cover real A/B instance records and SQL lookups, tenant/type/status
    rejection, malformed settings, missing endpoint, option precedence, anonymous
    key/environment isolation, credential rotation, builtin config retention and
    reload, real Parser.Invoke, selected-service errors without VLM fallback,
    and the existing SSRF boundary.
  • Two self-review passes traced persisted configuration through the actual
    runtime and reviewed error/secret/ownership boundaries. Normal commit hooks
    and git diff --check passed; hooks did not change the validated source tree.
  • Exact commands, native adaptation and validation record.

Validation limits: macOS tests used an isolated PCRE2 path-only overlay,
genuine ONNX Runtime 1.29.0/PDF 0.3.73 shared libraries and the real tokenizer
archive. No Go behavior was overlaid, and build/dependency files are unchanged.
At initial implementation time, the repository's unmodified macOS static-link
configuration and hosted Linux CI had not been validated. The October 20
acceptance above records the later exact-head hosted Linux result; the macOS
static-link limit remains. No real OCR/LLM inference, production DB/MinIO or full
ingestion E2E is claimed. SoMark fixtures return SUCCESS immediately and do not
validate asynchronous polling. No frontend source changed.

October 18 review-warning follow-up

Historical October 18 head: b1b16e08d57f323162f9d9992fb87c395ae96ad0. The follow-up addresses the touched-function doc-comment coverage warning with six owner-function comments (13 added comment lines in three existing PR files). It changes no executable code, test or threshold.

Focused tests, the complete related selection (28 selected packages plus two native-smoke packages, 30 total) and selected race scenarios passed again with -count=1 through unchanged build.sh. Formatting, diff checks and normal source hooks passed; the hooks preserved the tested tree. Follow-up validation and exact logs.

The before/after runtime captures and recording above remain at 691a50a5ddfac05e9c5fd66ca422a09d9c3092c9; they were not recaptured or relabeled for this comment-only change. The original native-link-only adaptation and unverified production scope remain unchanged.

On this pushed head, all five Actions jobs are SKIPPED by the repository's maintainer-controlled ci-label gate, not passing tests. No label or workflow was changed to bypass it. CodeRabbit's review of this exact head now reports 95% doc-comment coverage, all five pre-merge checks passed, and no actionable comments. This is an automated result, not human maintainer approval.

Implementation, self-review, verification and evidence preparation were
AI-assisted with OpenAI Codex. Historical local records are not human maintainer
approval or hosted-CI evidence; the current hosted result is reported separately above.

Missing-model review follow-up — October 19, 2026 (historical head)

Head: 72ec8472e8eb5edbee130522aaa48b93b1ac1ce5.

Addressed the missing-model review. Removed the three-line record-not-found early return: an explicit missing ID now returns handled=true through the existing wrapped lookup error, preserving errors.Is(err, gorm.ErrRecordNotFound). Existing models and bare-engine dispatch are unchanged.

New regressions cover both selector fields, both provider fixtures and actual Parser Invoke using persisted/reloaded synthetic SQLite canvas parameters. The old production owner fails eight cases (ten parent/subtest fail events); real Invoke previously reached generic VLM rendering/resolution/chat. Fixed behavior sends no fallback HTTP/model request and preserves persisted and runtime setup. Test-only VLM/native sentinels and the local services are synthetic, not real inference. Only two existing PR files changed.

  • focused: 3 test-executing packages, 12 top-level tests / 88 passing test/subtest events, 0 explicit skips; no failures.
  • full: 30 test-executing packages, 3664 top-level tests / 5562 passing test/subtest events, 5 explicit skips; no failures.
  • race: 3 test-executing packages, 12 top-level tests / 88 passing test/subtest events, 0 explicit skips; no failures.

Before/after behavior, exact commands, raw logs and automated review. Normal hooks passed and committed diffs match the frozen tested trees; exact remote heads and PR file lists were verified. Local Go checks use unchanged build.sh, a PCRE path-only overlay and the disclosed genuine same-version ORT 1.29.0 / PDF_oxide 0.3.73 shared TEST adapter. Production static/server builds, real OCR/models, production services and deployed UI are not validated. Appended native TestMain without model testdata does not execute m.Run; plain ok is not native unit/inference coverage. Existing screenshots/recordings retain their original capture provenance; no fresh visual capture is claimed for this follow-up.

Historical October 19 hosted checkpoint (not the current result)

Read at 2026-10-19T12:39:11.239Z independently of local validation:

  • ragflow_tests_infinity: in_progress
  • ragflow_go_integration: completed/success
  • ragflow_tests_elasticsearch: in_progress
  • ragflow_preflight: completed/success

Pending/skipped checks are not passes. Automated reviews and earlier-head approvals are not current-head human approval. AI-assisted with OpenAI Codex.

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ae19478b-c5ec-419c-8461-f51025c77742
📥 Commits

Reviewing files that changed from the base of the PR and between 72ec847 and 73917c6.

📒 Files selected for processing: 1
  • docs/guides/agent/ingestion_pipeline/configure_parser_component.md

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The Go ingestion pipeline resolves tenant model IDs and composite references for SoMark and OpenDataLoader PDF parsing. It validates selections, loads instance configuration at execution time, and preserves existing bare-engine handling.

Changes: Tenant PDF parser selection

Layer / File(s) Summary
Runtime parser configuration policy
internal/parser/parser/pdf_parser_common.go, internal/parser/parser/pdf_parser_opendataloader.go, internal/parser/parser/pdf_parser_somark.go, internal/parser/parser/pdf_parser_tenant_config_test.go
Adds runtime-only configuration that controls environment, credential, and option fallback for selected tenant parser instances. Tests cover selected and named configurations.
Tenant model resolution and dispatch
internal/ingestion/component/pdf_parser_model.go, internal/ingestion/component/pdf_vision_dispatch.go, internal/ingestion/component/pdf_parser_model_test.go
Resolves supported references, validates tenant model and instance data, and dispatches to the selected parser. Tests cover selection, precedence, options, credential rotation, SSRF enforcement, and failures without fallback.
Parser reference compatibility
internal/ingestion/pipeline/parser_tenant_reference_test.go, docs/guides/agent/ingestion_pipeline/configure_parser_component.md
Tests reference preservation through cleaning and JSON serialization. The guide documents supported references, precedence, configuration, and failure behavior.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant PDFVisionDispatch
  participant TenantModelRecords
  participant SelectedParser
  PDFVisionDispatch->>TenantModelRecords: Resolve tenant model and instance
  TenantModelRecords-->>PDFVisionDispatch: Return selected instance configuration
  PDFVisionDispatch->>SelectedParser: Send PDF using selected endpoint and credentials
  SelectedParser-->>PDFVisionDispatch: Return parse result or error
Loading

Suggested reviewers: jay77721, yannnnnnny

Merge Risk: ⚪ Minimal · up to 73917

No concrete merge-blocking risk is established by the available evidence.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: using selected tenant SoMark and OpenDataLoader instances in the parser.
Linked Issues check Passed Issue [#21027] requires tenant UUID and composite references to select the intended SoMark or OpenDataLoader parser and instance. The submitted implementation resolves both forms through the existing …
Out of Scope Changes check Passed The changes stay within [#21027]. The implementation connects existing SoMark and OpenDataLoader PDF parsers to tenant model references. The tests use local HTTP fixtures and DAO records to verify the…
Docstring Coverage Passed Docstring coverage is 95.45% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 8 files. (1 skipped: 1 …
Description check Passed The pull request includes the required Summary section and clearly explains the purpose, background, implementation scope, validation, limitations, and acceptance status.
Full details: Linked Issues check

Explanation

Issue [#21027] requires tenant UUID and composite references to select the intended SoMark or OpenDataLoader parser and instance. The submitted implementation resolves both forms through the existing provider, instance, and model DAOs. It validates tenant ownership, provider and instance linkage, active status, OCR type, endpoint, and credentials. It applies execution-time settings with no global credential fallback and preserves bare engine invocation. The dispatcher returns handled errors instead of falling through to generic VLM parsing. The added tests cover selector precedence, both providers and reference forms, request credentials, rejection cases, saved setup retention, credential rotation, and no fallback.

Full details: Out of Scope Changes check

Explanation

The changes stay within [#21027]. The implementation connects existing SoMark and OpenDataLoader PDF parsers to tenant model references. The tests use local HTTP fixtures and DAO records to verify the required dispatch and configuration behavior. The documentation describes the supported configuration. No unrelated frontend, schema, migration, dependency, workflow, template, generic driver, or parallel parser change is shown.

Full details: Docstring Coverage

Explanation

Docstring coverage is 95.45% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 22 functions across 8 files. (1 skipped: 1 unsupported.)

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit selects a model with care
Tenant credentials travel there
SoMark and OpenDataLoader parse
No secret settles in saved glass
Errors stop the fallback trail
Clean references keep the path in scale

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

@ZXLyyds100

Copy link
Copy Markdown
Contributor Author

Addressed the docstring-coverage warning
in b1b16e08d57f323162f9d9992fb87c395ae96ad0.

Independently checked the touched functions and added six owner-function
comments describing dispatch's handled-error contract, endpoint/key isolation,
and SoMark option defaults. The follow-up contains only 13 added comment lines
in three existing PR files; no executable code, tests, threshold or workflow
was changed.

Focused tests, the complete related selection (28 selected packages plus two
native-smoke packages), and the selected race scenarios passed again with
-count=1 through build.sh. Formatting and normal commit hooks passed and
preserved the tested tree. Exact commands and logs.

The original runtime screenshots/video remain explicitly labeled with capture
source 691a50a5; this comment-only follow-up does not relabel them. The same
native-link-only adaptation and production-validation limits still apply.
The five Actions jobs were skipped by the repository's ci-label gate; those
are not test passes. The automatic review has now refreshed for b1b16e08:
doc-comment coverage is 95%, all five pre-merge checks passed, and the recent
review generated no actionable comments. That is a bot result, not human
maintainer approval.

AI-assisted with OpenAI Codex.

@jay77721
jay77721 self-requested a review October 19, 2026 05:54
@jay77721 jay77721 added the ci Continue Integration label Oct 19, 2026

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the fix. One fail-closed issue in the explicit model path.

} else {
model, err = modelDAO.GetByID(ctx, db, selector)
if errorsIsRecordNotFound(err) {
return parser.ParseResult{}, false, nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The comment above maybeDispatchTenantPDFParser says a selected tenant reference never falls back, but a bare selected model ID that no longer exists returns handled=false, so the caller proceeds with the generic PDF parser.

This is reachable: resolvePDFVisionModelID accepts a valid-looking model UUID, and GetByID returning ErrRecordNotFound (deleted/stale model) now silently switches parsers.

Please fail closed here, e.g. return true with a selected PDF model not found error, and add a test covering a valid-looking UUID with no record.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 72ec8472e8. Removed the record-not-found handled=false special case, so missing selected IDs terminate with the existing wrapped tenant-PDF-model lookup error (errors.Is(..., gorm.ErrRecordNotFound) stays true).

Both selector fields are covered by helper and actual Parser Invoke tests with reloaded SQLite canvas params. The old source fails eight cases; its Invoke really reaches generic VLM rendering/resolution/chat. The fix makes no fallback request and leaves persisted/runtime config unchanged. Fresh focused/race runs each pass 88 events; all 30 test-executing related packages pass (5,562 events, five explicit skips). Normal hooks passed. Before/after logs, review and native fixture limits. AI-assisted with OpenAI Codex.

@jay77721
jay77721 requested a review from yuzhichang October 20, 2026 01:55
@xugangqiang

Copy link
Copy Markdown
Contributor

LGTM

@jay77721

Copy link
Copy Markdown
Member

@ZXLyyds100 pls fix conflicts ,thanks !!

@ZXLyyds100

ZXLyyds100 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@jay77721 Addressed the conflict request in 73917c62badf86c59fccf4664c9273b9a4696dd4, merging upstream f2b9d65ef1 without rewriting published history.

The sole manual conflict was the Parser guide. It now retains both the complete
MinerU controls section and the tenant SoMark/OpenDataLoader section, with
separate valid JSON examples; upstream's image/PaddleOCR documentation is
preserved. The effective PR remains nine files, and GitHub reports it mergeable.

All seven non-dispatch Go files are byte-identical to the previous tested feature
head. The merged dispatcher preserves all upstream code plus only this PR's
original tenant-dispatch insertion. Fourteen local merge/document/JSON/scope
checks and all nine applicable normal pre-commit checks pass.

Application/native/race suites were not rerun locally for this documentation
conflict; the existing local test/capture records retain their original source
provenance. The exact new-head Linux CI run
has now completed successfully: preflight, Go integration, Infinity and
Elasticsearch jobs executed successfully. I verified the actual Go unit,
integration and both backend API test steps. The native-backend job was skipped
without steps; this is not native/inference coverage or a fresh local race run.
CodeRabbit reviewed this head with zero actionable comments; no current-head
human approval is implied. The PR description now identifies this head and
separates these hosted results from the historical local validation/captures.
No workflow, label, threshold or approval gate was changed. AI-assisted with
OpenAI Codex.

@yuzhichang
yuzhichang merged commit ab85152 into infiniflow:main Oct 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Go ingestion: resolve tenant model references for SoMark and OpenDataLoader PDF parsing

4 participants