Skip to content

refactor(pipeline): remove dead output_format from ingestion templates - #21266

Merged
yuzhichang merged 3 commits into
infiniflow:mainfrom
jay77721:chore/remove-template-output-format
Oct 21, 2026
Merged

yuzhichang merged 3 commits into
infiniflow:mainfrom
jay77721:chore/remove-template-output-format

Conversation

@jay77721

@jay77721 jay77721 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Summary

The Go Parser component exposes JSON only: normalizeParserOutputFormats (internal/ingestion/component/parser.go) overwrites every family's output_format with "json" when the Parser component is built, after the template params are overlaid. A template-baked output_format therefore never reaches the parser that would read it — the 88 keys across the 12 builtin ingestion templates are redundant config that states an intent the runtime discards. This PR drops them from both dsl.components params and graph.nodes form setups. Runtime output_format stays json; no behavior change.

The parsers do still read output_format (audio, csv, doc, docx, email, markdown, pdf, picture, pptx, xls, xlsx), but they only ever see the normalized "json". The per-family defaults the removed values relied on are therefore all "json", except audio, whose own fallback is "text" (audio_parser.go) — and that fallback is unreachable too, because the normalized value is present and non-empty.

Related Issue

None.

Changes

  • Delete all output_format keys from internal/ingestion/pipeline/template/ingestion_pipeline_*.json (12 files, 88 deletions, 0 additions).
  • Covers both copies per template: dsl.components.Parser params and dsl.graph.nodes Parser form setups. Each copy carried 44 keys: 37 json, 4 text (audio, email ×2, video), 3 html (spreadsheet ×3).
  • Untouched: outputs.{html,text,json,markdown} wire definitions, Extractor/Tokenizer/Chunker params (they never carried this key), frontend and backend code.

Test Plan

  • bash build.sh --test ./internal/ingestion/pipeline/... ./internal/ingestion/task/... ./internal/dao/ ./internal/service/ ./internal/handler/: OK.
  • New TestBuiltinTemplatesCarryNoParserOutputFormat (internal/ingestion/pipeline/template_output_format_test.go) walks every registered builtin template and rejects an output_format key in either copy of the Parser configuration — the dsl.components family setups and the dsl.graph.nodes form setups. It replaces the narrower per-family assertions the general-template contract test used to carry, which left the other eleven templates' graph copies unchecked.
  • grep output_format in template dir: 0 matches remaining.

Parser normalizes every setup to json at build time
(normalizeParserOutputFormats), so the 88 output_format keys
across the 12 builtin templates are dead config. Drop them from
both dsl.components params and graph.nodes form setups; runtime
output_format stays json.
@jay77721 jay77721 added go Pull requests that update go code ☯️ refactor Pull request that refactor/refine code size:M This PR changes 30-99 lines, ignoring generated files. ci Continue Integration labels Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 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: 7f5a5073-b6b3-4716-bf67-995caeb08650
📥 Commits

Reviewing files that changed from the base of the PR and between 2623f83 and c9ed063.

📒 Files selected for processing: 2
  • internal/ingestion/pipeline/general_template_contract_test.go
  • internal/ingestion/pipeline/template_output_format_test.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

Twelve ingestion pipeline templates remove explicit output_format settings from parser configurations and Parser node setups. Contract tests, golden expectations, and a new template-wide validation test reflect the updated defaults.

Changes: Ingestion parser templates

Layer / File(s) Summary
Remove explicit parser output formats
internal/ingestion/pipeline/template/ingestion_pipeline_*.json
Parser parameters and Parser node setups no longer specify json, text, or html output formats. Other parsing and preprocessing settings remain.
Update parser default contracts
internal/ingestion/pipeline/general_template_contract_test.go, internal/ingestion/task/pipeline_executor_defaults_test.go, internal/ingestion/pipeline/template_output_format_test.go
Existing assertions and golden expectations match the updated defaults. A new test checks registered templates for per-family output_format declarations in runtime and frontend configurations.

Priority: ⬇️ Low

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

Change: Refactor

Merge Risk: ⚪ Minimal · up to c9ed0

Removing the redundant template settings does not appear to change parser output. The change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: removing obsolete output_format settings from ingestion templates.
Description check Passed The description includes the required Summary section and provides clear background, scope, behavior impact, and test validation details.
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.
  • 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 each parser line
No extra format keys remain to find
The templates keep their settings true
The tests check every setup too
Clean defaults now hop in view

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

Templates no longer carry output_format; the Parser defaults to
json at build time. Assert absence instead of json, and strip the
key from builtinComponentParamsGolden.

@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.

Review summary

Scope — 12 ingestion pipeline templates under
internal/ingestion/pipeline/template/ plus the two contract tests.
Base main, merge-base df9432f, head 2623f83. Pure deletions: 106
lines removed, 18 added (all in tests).

Coverage — 12 reviewable files, 12 reviewed, 0 skipped (100%).
general_template_contract_test.go and pipeline_executor_defaults_test.go
were filtered out by the default test-file exclusion; I read both diffs to see
what the PR now asserts.

Verdict — the cleanup is the right instinct: most of these keys repeat the
backend default, and the template JSON is easier to read without them. One of
them is not redundant, though, and it changes behaviour on a live path (P1).
Two notes below on the framing and on a latent TCADP case.

Principles applied — §1 (minimal necessary change): satisfied except for
the one non-redundant key, which should either stay or move to its own PR with
a stated outcome. §2: the change keeps configuration where the code reads it;
the P2 note is about documenting which layer actually consumes the key so the
next cleanup does not remove a live one. §3 (value judgment): a 106-line
deletion with no behavioural intent is high value only if it is truly
no-op — that is exactly what fails in P1.


P1 — "output_format": "text" for the email family is not dead: removing it flips email parsing to the JSON branch

output_format is read from the setup map by configureParserFromSetups
(parser_dispatch.go:62, cfg.ConfigureFromSetup(map[string]any(setup))), and
EmailParser acts on it:

  • email_parser.go:61 — p.outputFormat = setup["output_format"]
  • email_parser.go:53 / :125 — default is "json", not "text"
  • email_parser.go:193 — if outputFormat == "text" { return ParseResult{OutputFormat: "text", Text: text} }

So before this PR ingestion_pipeline_email.json and the email setup in
ingestion_pipeline_general.json forced the single-text-item branch; after it
they take the JSON branch, which emits content as one item, a separate
searchableEmailHeaders item, and one item per attachment. That changes the
indexed item count and the chunk text of every email document on its next
parse — a behaviour change riding inside a PR titled "remove dead
output_format", and one the updated contract tests do not cover (they only
assert absence for spreadsheet and image).

Either keep both "output_format": "text" entries, or move the email switch to
its own change with the new chunk shape stated up front.

P2 — The premise should be "redundant", not "dead": ten parsers read this key

The statement that matters for the next reader is narrower than the title
suggests. output_format is consumed by
audio_parser.go:57, csv_parser.go:77, doc_parser.go:48,
docx_parser.go:56, email_parser.go:61, markdown_parser.go:80,
pdf_parser_common.go:183, picture_parser.go:61, pptx_parser.go:79,
xls_parser.go:59, xlsx_parser.go:55. Only two parsers ignore it outright
(html_parser.go, and docx sets it without reading it).

What is actually true is that each removed value happens to equal the
backend's default: json for pdf/doc/markdown/text&code/spreadsheet/image,
text for audio (audio_parser.go:77 falls back to "text"). Please say that
in the description, and list the families whose default it relies on, so a
future reader does not conclude the key is unread and delete a live one — which
is what P1 above is.

P3 — "output_format": "html" for spreadsheet is only dead on the current parse method

ingestion_pipeline_one.json, _qa.json and _table.json drop
"output_format": "html" from their spreadsheet setups. That is currently a
no-op because those setups also pin "parse_method": "DeepDOC", and the local
spreadsheet path hardcodes spreadsheetOutputFormat = "json"
(parse_result.go:102, used at csv_parser.go:123, :150,
xls_parser.go:116, xlsx_parser.go:178). p.OutputFormat is only passed
through on the TCADP path (csv_parser.go:108, xlsx_parser.go:99).

So the removal is safe today, but it removes the only place that expressed
"tables as HTML" for these templates: if an operator switches one of them to
parse_method: "tcadp", the output silently becomes JSON instead of the HTML
that was previously requested. A one-line note in the PR description is enough;
no code change needed.

The previous contract test asserted the absence of output_format only for
the general template's spreadsheet and image families, leaving the other
eleven templates unchecked — including the graph.nodes copy the frontend
renders as the Parser form, which no test covered at all.

Add a test that walks every registered builtin template and rejects an
output_format key in either copy of the Parser configuration: the
dsl.components family setups and the dsl.graph.nodes form setups. The
Parser runtime overwrites every family's output_format with "json" when
the component is built, so a template-baked value never reaches the
parser that would read it; the key is dead configuration.

Drop the now-redundant per-family assertions from the general template
contract test, which this test subsumes.
@jay77721
jay77721 requested a review from yuzhichang October 21, 2026 05:37

@jay77721 jay77721 left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for the review. P2's wording point is right and I've taken it; P1 and P3 rest on a premise I believe doesn't hold.

The template value never reaches a parser. normalizeParserOutputFormats (internal/ingestion/component/parser.go:208) runs after the template params are overlaid, and overwrites every family's output_format with "json" unconditionally. NewParserComponent is the only production construction path for the Parser component, so a template-baked value is discarded at build time.

P1 (email "text") — email already took the JSON branch before this PR. Checked against the pre-PR template:

TEMPLATE email setup output_format = text
AFTER NewParserComponent email setup output_format = json
END-TO-END email ParseResult.OutputFormat = "json" (items=2, text len=0)

The end-to-end line drives dispatchParse with a real .eml. The email was already emitted as JSON items — content plus the searchable EmailHeaders item — so removing the key changes neither the item count nor the chunk text.

P3 (spreadsheet "html") — the TCADP path already received "json". CSVParser.OutputFormat, passed to parseWithTCADP (csv_parser.go:108), is read from the normalized setup, so it's "json", not the template's "html". Switching to parse_method: tcadp doesn't silently drop an HTML request — there was none.

P2 — description updated. Reworded to state that the runtime overwrites the value, and listed the parsers that read the key. Two small corrections: docx does read it (docx_parser.go:56 stores it, :119 branches on it), and the audio fallback (audio_parser.go:78) is only reachable when the setup carries no output_format at all, which the normalized path never produces.

Your point did expose a test gap — now fixed. The updated tests only asserted the absence for general's spreadsheet and image; the other eleven templates' graph.nodes copies weren't checked at all. Added TestBuiltinTemplatesCarryNoParserOutputFormat, which walks every registered template and rejects output_format in both copies.

Out of scope, worth flagging: the same dead key sits in three agent templates (internal/agent/templates/{advanced_ingestion_pipeline,chunk_summary,title_chunker}.json — 60 keys). Same path, equally inert. Keeping this PR to the ingestion templates to keep the review surface small; will clean those up separately.

@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.

Review summary

Scope — 12 builtin ingestion templates plus the template-wide contract test, with test-file filtering manually accounted for. Base main, merge-base df9432f, head c9ed063. Total: 15 files, 12 reviewable by OCR, 3 default-excluded tests; I reviewed all 15 (100% coverage, 0 skipped).

Verdict — LGTM. The premise now checks out against the construction path: NewParserComponent overlays template params and then normalizeParserOutputFormats overwrites every setup with json (internal/ingestion/component/parser.go:149-204), so the deleted values never reached a parser. The email and spreadsheet cases raised in the prior review are therefore not behavior changes.

Validation — all 12 templates parse as JSON; both copies (dsl.components and graph.nodes) have the same family set before and after, with no remaining output_format keys; the new test walks every registered template. Ran bash build.sh --test ./internal/ingestion/pipeline/... ./internal/ingestion/task/... after building the worktree's C++ archive: all packages passed.

Principles applied — §1: the test change now subsumes the narrower per-family assertions instead of duplicating them. §2: the removal keeps normalization at the Parser construction boundary, where the runtime actually owns the value. §3: deleting dead configuration reduces the template surface without adding a second path.

No blocking findings. Thanks for the detailed rebuttal and for closing the graph-copy test gap.

@yuzhichang
yuzhichang merged commit 18d3da2 into infiniflow:main Oct 21, 2026
6 checks passed
@jay77721
jay77721 deleted the chore/remove-template-output-format branch November 5, 2026 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration go Pull requests that update go code ☯️ refactor Pull request that refactor/refine code size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants