Skip to content

feat(parser): require a text source for images when vision enhancement is off - #20839

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
jay77721:feat/image-require-text-source
Oct 12, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
jay77721:feat/image-require-text-source

Conversation

@jay77721

@jay77721 jay77721 commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

Summary

An image with OCR off and vision enhancement disabled carries no text, and the Tokenizer drops it, so the document indexes nothing without telling the user why. This PR makes that dead configuration hard to write by mistake: the backend rejects it at build time (which also covers direct API calls bypassing the form), and the frontend blocks both switches with a warning plus a save-time schema check.

Related Issue

None.

Changes

  • Backend (internal/ingestion/component/parser.go): ParserComponent.Check() returns an error when the image family has no text source (OCR off via ocr_enabled or legacy parse_method) while enable_vision_enhancement is off. Shares the imageSetupRunsOCR helper between Check() and the maybeDispatchImage selection logic, so validation and dispatch cannot drift.
  • Frontend (image-form-fields.tsx, vision-form-fields.tsx): turning OCR off while enhancement is off (and vice versa) shows flow.imageTextSourceRequired and refuses the toggle.
  • Frontend (schema.ts): FormSchema.superRefine rejects image ocr_enabled: false + enhancement off at save time for normalized form values (the form always materializes the switch on load; legacy parse_method shapes are still caught by backend Check()).
  • i18n (en.ts, zh.ts): new flow.imageTextSourceRequired key.
  • Tests: updated parser_check_test.go / media_dispatch_test.go expectations, new image-form-fields.test.tsx, extended schema.test.ts / vision-form-fields.test.tsx.

Test Plan

bash build.sh --test ./internal/ingestion/component/ ./internal/ingestion/pipeline/... ./internal/ingestion/task/...
cd web && npx jest src/pages/agent/form/parser-form src/pages/agent/utils.test.ts
cd web && npx oxfmt --check <changed files> && npx oxlint <changed files>
gofmt -l internal/ingestion/component/*.go && git diff --check

All green locally: Go component/pipeline/task packages pass, 66 frontend tests pass, format/lint clean.

…t is off

An image with OCR off and vision enhancement disabled carries no text and is dropped by the Tokenizer, indexing nothing silently. Reject that configuration at build time in ParserComponent.Check, block both switches in the parser form with a warning, and add a FormSchema cross-check so the dead combination cannot be saved.
@jay77721 jay77721 added parsing 💞 feature Feature request, pull request that fullfill a new feature. go Pull requests that update go code 🧰 typescript Pull requests that update Typescript code ci Continue Integration labels Oct 12, 2026
@coderabbitai

coderabbitai Bot commented Oct 12, 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: d294e479-ff1a-4770-a97b-d1973925e18d

📥 Commits

Reviewing files that changed from the base of the PR and between 0ac3a99 and 5b033e0.


📒 Files selected for processing (1)
  • internal/ingestion/component/media_dispatch.go

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



📝 Walkthrough
📝 Walkthrough

Walkthrough

Image parser validation and form controls require at least one image text source: OCR or vision enhancement. Tests cover parser checks, schema validation, and switch behavior.

Changes

Image Text Source

Layer / File(s) Summary
Parser validation
internal/ingestion/component/parser.go, internal/ingestion/component/media_dispatch.go, internal/ingestion/component/parser_check_test.go, internal/ingestion/component/media_dispatch_test.go
Parser validation accepts OCR or vision enhancement as an image text source. OCR detection uses ocr_enabled when set and otherwise checks the legacy parse_method. Tests cover validation and parser construction.
Form schema validation
web/src/pages/agent/form/parser-form/schema.ts, web/src/pages/agent/form/parser-form/schema.test.ts
FormSchema rejects image setups with OCR disabled when vision enhancement is off. Tests check the issue path and valid configurations.
Form switch guards
web/src/pages/agent/form/parser-form/image-form-fields.tsx, web/src/pages/agent/form/parser-form/image-form-fields.test.tsx, web/src/pages/agent/form/parser-form/vision-form-fields.tsx, web/src/pages/agent/form/parser-form/vision-form-fields.test.tsx, web/src/locales/en.ts, web/src/locales/zh.ts
The OCR and vision enhancement switches block changes that would disable both text sources and show a localized warning. Tests cover both guards.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix


Merge Risk: ⚪ Minimal · up to 5b033

Image configurations consistently require OCR or vision enhancement, and no remaining merge-blocking behavior risk is established.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 12 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check Passed The title clearly and concisely describes the main change: requiring a text source for images when vision enhancement is disabled.
Description check Passed The description includes a complete Summary with background and purpose. It also provides implementation details, related issue status, and a test plan with reported results.

  • Fix all pre-merge checks with AI
  • 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 checks the image flow,
“Keep one text source on,” says so.
OCR or vision lights the way,
The guarded switches pause the play.
Tests hop through each path today.

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

Check() and maybeDispatchImage encoded the same OCR-selection truth table twice. Keep imageSetupRunsOCR as the single source so the validation and the dispatch cannot drift.
@xugangqiang

Copy link
Copy Markdown
Contributor

LGTM

@jay77721
jay77721 requested a review from yuzhichang October 12, 2026 11:08
@yuzhichang
yuzhichang merged commit deb1235 into infiniflow:main Oct 12, 2026
6 checks passed
@jay77721
jay77721 deleted the feat/image-require-text-source branch October 16, 2026 03:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration 💞 feature Feature request, pull request that fullfill a new feature. go Pull requests that update go code parsing 🧰 typescript Pull requests that update Typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants