Repository navigation
refactor(pipeline): remove dead output_format from ingestion templates - #21266
Conversation
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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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.
Summary
The Go Parser component exposes JSON only:
normalizeParserOutputFormats(internal/ingestion/component/parser.go) overwrites every family'soutput_formatwith"json"when the Parser component is built, after the template params are overlaid. A template-bakedoutput_formattherefore 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 bothdsl.componentsparams andgraph.nodesform setups. Runtimeoutput_formatstaysjson; 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
output_formatkeys frominternal/ingestion/pipeline/template/ingestion_pipeline_*.json(12 files, 88 deletions, 0 additions).dsl.components.Parser paramsanddsl.graph.nodesParser formsetups. Each copy carried 44 keys: 37json, 4text(audio, email ×2, video), 3html(spreadsheet ×3).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.TestBuiltinTemplatesCarryNoParserOutputFormat(internal/ingestion/pipeline/template_output_format_test.go) walks every registered builtin template and rejects anoutput_formatkey in either copy of the Parser configuration — thedsl.componentsfamily setups and thedsl.graph.nodesform 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_formatin template dir: 0 matches remaining.