Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

fix(ingestion): flatten legacy nested Parser setups from Python-era canvases (#20285)

xugangqiang313bdba3689d
diff --git a/internal/ingestion/component/parser.go b/internal/ingestion/component/parser.go
index a99ceef5a3..f44cd62f5e 100644
--- a/internal/ingestion/component/parser.go
+++ b/internal/ingestion/component/parser.go
@@ -136,6 +136,9 @@ func NewParserComponent(params map[string]any) (runtime.Component, error) {
normalizeParserOutputFormats(s)
return &ParserComponent{setups: s}, nil
}
+ // Canvases saved by the Python-era frontend nest the per-family setups
+ // under a "setups" key; lift them so every family lands at the top level.
+ params = schema.FlattenLegacyParserSetups(params)
for k, raw := range params {
if k == "outputs" || k == "allowed_output_format" {
continue
diff --git a/internal/ingestion/component/parser_test.go b/internal/ingestion/component/parser_test.go
index 593cb9c511..75b0cbdd5d 100644
--- a/internal/ingestion/component/parser_test.go
+++ b/internal/ingestion/component/parser_test.go
@@ -204,6 +204,51 @@ func TestNewParserComponentNormalizesOutputFormatToJSON(t *testing.T) {
}
}
+// A canvas saved by the Python frontend stores the Parser params in the
+// nested shape {outputs, setups: {pdf: {...}}}; the Go component reads the
+// flat shape with file families as top-level keys. The nested group must be
+// lifted instead of being treated as a bogus "setups" file family.
+func TestNewParserComponentFlattensNestedSetups(t *testing.T) {
+ component, err := NewParserComponent(map[string]any{
+ "outputs": map[string]any{"html": map[string]any{"type": "string"}},
+ "setups": map[string]any{
+ "pdf": map[string]any{"parse_method": "vision"},
+ "spreadsheet": map[string]any{"html4excel": true},
+ },
+ })
+ if err != nil {
+ t.Fatalf("NewParserComponent: %v", err)
+ }
+
+ parserComponent := component.(*ParserComponent)
+ if _, ok := parserComponent.setups["setups"]; ok {
+ t.Error("legacy nested \"setups\" key must not become a parser setup family")
+ }
+ if got := parserComponent.setups["pdf"]["parse_method"]; got != "vision" {
+ t.Errorf("pdf parse_method = %v, want vision (nested setups not flattened)", got)
+ }
+ if got := parserComponent.setups["spreadsheet"]["html4excel"]; got != true {
+ t.Errorf("spreadsheet html4excel = %v, want true (nested setups not flattened)", got)
+ }
+
+ // When both shapes carry the same family, the top-level (Go-native, flat)
+ // entry wins.
+ mixed, err := NewParserComponent(map[string]any{
+ "pdf": map[string]any{"lang": "English"},
+ "setups": map[string]any{"pdf": map[string]any{"parse_method": "vision"}},
+ })
+ if err != nil {
+ t.Fatalf("NewParserComponent(mixed): %v", err)
+ }
+ mixedPC := mixed.(*ParserComponent)
+ if got := mixedPC.setups["pdf"]["parse_method"]; got != "vision" {
+ t.Errorf("mixed: pdf parse_method = %v, want vision", got)
+ }
+ if got := mixedPC.setups["pdf"]["lang"]; got != "English" {
+ t.Errorf("mixed: pdf lang = %v, want English", got)
+ }
+}
+
// TestParserComponent_Invoke_TextInput covers the happy path:
// UTF-8 text input, no form-feeds, default page_size. The
// component must emit exactly one page carrying the full text
diff --git a/internal/ingestion/component/schema/parser.go b/internal/ingestion/component/schema/parser.go
index e70b09b5a2..32a4c9508f 100644
--- a/internal/ingestion/component/schema/parser.go
+++ b/internal/ingestion/component/schema/parser.go
@@ -21,6 +21,53 @@ package schema
// so a free-form map best mirrors the Python dict literal.
type ParserSetup map[string]any
+// FlattenLegacyParserSetups normalizes a Parser param map saved by the
+// Python-era frontend. That shape nests the per-family setups under a
+// "setups" key ({outputs, setups: {pdf: {...}}}), while the Go backend —
+// the component runtime and the parser_config storage alike — uses the flat
+// shape with file families as top-level keys. The nested families are
+// lifted to the top level; when both shapes carry the same family the
+// entries are field-merged with the top-level (Go-native) fields winning,
+// mirroring the shallow per-field overlay NewParserComponent applies over
+// its defaults. Maps without a nested "setups" object are returned
+// unchanged.
+func FlattenLegacyParserSetups(params map[string]any) map[string]any {
+ nested, ok := params["setups"].(map[string]any)
+ if !ok {
+ return params
+ }
+ flat := make(map[string]any, len(params)+len(nested))
+ for family, cfg := range nested {
+ flat[family] = cfg
+ }
+ for k, v := range params {
+ if k == "setups" {
+ continue
+ }
+ flat[k] = mergeSetupEntry(flat[k], v)
+ }
+ return flat
+}
+
+// mergeSetupEntry field-merges two same-family setup maps, with the
+// top-level entry winning on conflicting keys. Non-map values (or a
+// non-map on either side) replace outright.
+func mergeSetupEntry(nested, top any) any {
+ nestedMap, ok1 := nested.(map[string]any)
+ topMap, ok2 := top.(map[string]any)
+ if !ok1 || !ok2 {
+ return top
+ }
+ merged := make(map[string]any, len(nestedMap)+len(topMap))
+ for k, v := range nestedMap {
+ merged[k] = v
+ }
+ for k, v := range topMap {
+ merged[k] = v
+ }
+ return merged
+}
+
// ParserOutputs is the result of invoking the Parser component. The
// wire format is "json", with structured JSON items as the only payload.
type ParserOutputs struct {
diff --git a/internal/ingestion/component/schema/schema_test.go b/internal/ingestion/component/schema/schema_test.go
index 4cf37c12e1..db1f7ce946 100644
--- a/internal/ingestion/component/schema/schema_test.go
+++ b/internal/ingestion/component/schema/schema_test.go
@@ -619,4 +619,69 @@ func TestContextualTextConcatenatesMediaContext(t *testing.T) {
// helpers
// ---------------------------------------------------------------------------
+func TestFlattenLegacyParserSetups(t *testing.T) {
+ cases := []struct {
+ name string
+ params map[string]any
+ want map[string]any
+ }{
+ {
+ name: "nested setups lifted",
+ params: map[string]any{
+ "outputs": map[string]any{"html": map[string]any{"type": "string"}},
+ "setups": map[string]any{
+ "pdf": map[string]any{"parse_method": "vision"},
+ },
+ },
+ want: map[string]any{
+ "outputs": map[string]any{"html": map[string]any{"type": "string"}},
+ "pdf": map[string]any{"parse_method": "vision"},
+ },
+ },
+ {
+ name: "flat params unchanged",
+ params: map[string]any{
+ "pdf": map[string]any{"parse_method": "deepdoc"},
+ },
+ want: map[string]any{
+ "pdf": map[string]any{"parse_method": "deepdoc"},
+ },
+ },
+ {
+ name: "empty setups map removed",
+ params: map[string]any{
+ "setups": map[string]any{},
+ },
+ want: map[string]any{},
+ },
+ {
+ name: "same family field-merged with top-level winning",
+ params: map[string]any{
+ "pdf": map[string]any{"lang": "English"},
+ "setups": map[string]any{"pdf": map[string]any{"parse_method": "vision", "lang": "Chinese"}},
+ },
+ want: map[string]any{
+ "pdf": map[string]any{"parse_method": "vision", "lang": "English"},
+ },
+ },
+ {
+ name: "non-map setups value left alone",
+ params: map[string]any{
+ "setups": "bogus",
+ },
+ want: map[string]any{
+ "setups": "bogus",
+ },
+ },
+ }
+ for _, tc := range cases {
+ t.Run(tc.name, func(t *testing.T) {
+ got := FlattenLegacyParserSetups(tc.params)
+ if !reflect.DeepEqual(got, tc.want) {
+ t.Errorf("FlattenLegacyParserSetups() = %#v, want %#v", got, tc.want)
+ }
+ })
+ }
+}
+
func ptrString(s string) *string { return &s }
diff --git a/internal/ingestion/pipeline/component_params.go b/internal/ingestion/pipeline/component_params.go
index f9c73e3e2b..a06fab7d89 100644
--- a/internal/ingestion/pipeline/component_params.go
+++ b/internal/ingestion/pipeline/component_params.go
@@ -3,6 +3,8 @@ package pipeline
import (
"encoding/json"
"fmt"
+
+ "ragflow/internal/ingestion/component/schema"
)
// ComponentParamsSchema describes the full set of user-configurable parameters
@@ -57,6 +59,12 @@ func ExtractAllComponentParams(dslJSON []byte) ([]ComponentParamsSchema, error)
}
params[k] = deepCopyValue(v)
}
+ // Canvases saved by the Python-era frontend nest the Parser's
+ // per-family setups under a "setups" key; lift them so the extracted
+ // defaults (and the parser_config built from them) stay flat.
+ if isParserComponent(cpnID, comp.Obj.ComponentName) {
+ params = schema.FlattenLegacyParserSetups(params)
+ }
out = append(out, ComponentParamsSchema{
CpnID: cpnID,
ComponentName: comp.Obj.ComponentName,
diff --git a/internal/ingestion/pipeline/component_params_test.go b/internal/ingestion/pipeline/component_params_test.go
index 42244a2e14..58c754ebdb 100644
--- a/internal/ingestion/pipeline/component_params_test.go
+++ b/internal/ingestion/pipeline/component_params_test.go
@@ -83,22 +83,23 @@ func TestExtractAllComponentParams(t *testing.T) {
if parser.ComponentName != "Parser" {
t.Errorf("Parser.ComponentName = %q, want %q", parser.ComponentName, "Parser")
}
- // ParamsDefaults must contain "setups", must NOT contain "outputs".
- if _, ok := parser.ParamsDefaults["setups"]; !ok {
- t.Errorf("Parser.ParamsDefaults missing key %q", "setups")
+ // ParamsDefaults must be flat: file families at the top level, with the
+ // legacy nested "setups" group lifted and "outputs" excluded.
+ if _, ok := parser.ParamsDefaults["setups"]; ok {
+ t.Errorf("Parser.ParamsDefaults should NOT contain %q (flattened)", "setups")
}
if _, ok := parser.ParamsDefaults["outputs"]; ok {
t.Errorf("Parser.ParamsDefaults should NOT contain %q (excluded)", "outputs")
}
- if setups, ok := parser.ParamsDefaults["setups"].(map[string]any); !ok {
- t.Errorf("Parser.ParamsDefaults[\"setups\"] is not a map: %T", parser.ParamsDefaults["setups"])
- } else {
- if _, ok := setups["pdf"]; !ok {
- t.Errorf("Parser setups missing key %q", "pdf")
- }
- if _, ok := setups["spreadsheet"]; !ok {
- t.Errorf("Parser setups missing key %q", "spreadsheet")
- }
+ pdf, ok := parser.ParamsDefaults["pdf"].(map[string]any)
+ if !ok {
+ t.Fatalf("Parser.ParamsDefaults[\"pdf\"] is not a map: %T", parser.ParamsDefaults["pdf"])
+ }
+ if pdf["parse_method"] != "deepdoc" {
+ t.Errorf("Parser pdf parse_method = %v, want deepdoc", pdf["parse_method"])
+ }
+ if _, ok := parser.ParamsDefaults["spreadsheet"]; !ok {
+ t.Errorf("Parser ParamsDefaults missing key %q", "spreadsheet")
}
// --- Tokenizer ---
@@ -129,6 +130,42 @@ func TestExtractAllComponentParams(t *testing.T) {
}
}
+func TestExtractAllComponentParams_ParserFlatSetupsPassThrough(t *testing.T) {
+ // A canvas saved by the Go frontend already stores the Parser params in
+ // the flat shape; extraction must pass them through unchanged.
+ dsl := map[string]any{
+ "components": map[string]any{
+ "Parser:Flat": map[string]any{
+ "obj": map[string]any{
+ "component_name": "Parser",
+ "params": map[string]any{
+ "outputs": map[string]any{},
+ "pdf": map[string]any{"parse_method": "deepdoc"},
+ },
+ },
+ },
+ },
+ }
+ dslJSON, err := json.Marshal(dsl)
+ if err != nil {
+ t.Fatalf("marshal fixture: %v", err)
+ }
+ schemas, err := ExtractAllComponentParams(dslJSON)
+ if err != nil {
+ t.Fatalf("ExtractAllComponentParams: %v", err)
+ }
+ if len(schemas) != 1 {
+ t.Fatalf("expected 1 component, got %d", len(schemas))
+ }
+ params := schemas[0].ParamsDefaults
+ if _, ok := params["pdf"]; !ok {
+ t.Error("flat pdf family missing from ParamsDefaults")
+ }
+ if _, ok := params["setups"]; ok {
+ t.Error("flat params must not gain a \"setups\" key")
+ }
+}
+
func TestExtractAllComponentParams_EmptyDSL(t *testing.T) {
dsl := map[string]any{
"components": map[string]any{},
diff --git a/internal/ingestion/pipeline/pipeline_params.go b/internal/ingestion/pipeline/pipeline_params.go
index abb33af14a..65ff4cf5fe 100644
--- a/internal/ingestion/pipeline/pipeline_params.go
+++ b/internal/ingestion/pipeline/pipeline_params.go
@@ -106,6 +106,37 @@ func isCompilerComponent(cpnID string) bool {
strings.HasPrefix(lowerID, "compiler_")
}
+// isParserComponent returns true if the component name or component ID
+// indicates a Parser component.
+func isParserComponent(cpnID, componentName string) bool {
+ return strings.EqualFold(componentName, "parser") ||
+ strings.HasPrefix(strings.ToLower(cpnID), "parser:")
+}
+
+// NormalizeParserConfigSetups lifts legacy nested Parser "setups" entries in
+// a parser_config-shaped map ({cpnID: params}) into the flat per-family
+// shape. The runtime merges such a map over the DSL-baked component params
+// with override-wins-on-top-level-key semantics, so a nested entry must be
+// flattened BEFORE the merge — otherwise the DSL's flat families win over
+// the override once NewParserComponent applies its own top-level-wins
+// flattening. Non-Parser entries and nil maps pass through untouched.
+func NormalizeParserConfigSetups(parserConfig map[string]any) map[string]any {
+ if parserConfig == nil {
+ return nil
+ }
+ for cpnID, raw := range parserConfig {
+ if !isParserComponent(cpnID, "") {
+ continue
+ }
+ params, ok := raw.(map[string]any)
+ if !ok {
+ continue
+ }
+ parserConfig[cpnID] = schema.FlattenLegacyParserSetups(params)
+ }
+ return parserConfig
+}
+
// getComponentParamWhitelist returns the dynamic parameter whitelist for a component type.
func getComponentParamWhitelist(cpnID string) (map[string]struct{}, bool) {
if isExtractorComponent(cpnID, "") {
@@ -172,6 +203,13 @@ func CleanComponentParams(dslJSON []byte, rawConfig map[string]interface{}) map[
if componentNames[key] == "GeneralChunker" {
params = normalizeGeneralComponentParams(params)
}
+ // Legacy parser_config rows (or canvases) saved by the Python-era
+ // frontend nest the Parser's setups under a "setups" key; lift them
+ // before filtering, otherwise the families are dropped as unknown
+ // params against the flat DSL schema keys.
+ if isParserComponent(key, componentNames[key]) {
+ params = schema.FlattenLegacyParserSetups(params)
+ }
dynamicWhitelist, hasDynamic := getComponentParamWhitelist(key)
if isExtractorComponent(key, "") {
params = NormalizeExtractorParams(params)
diff --git a/internal/ingestion/pipeline/pipeline_params_test.go b/internal/ingestion/pipeline/pipeline_params_test.go
index 58ea91adf0..59b4f3a748 100644
--- a/internal/ingestion/pipeline/pipeline_params_test.go
+++ b/internal/ingestion/pipeline/pipeline_params_test.go
@@ -231,6 +231,190 @@ func TestBuildParserConfig_ShallowMerge_NestedParam(t *testing.T) {
}
}
+// A canvas saved by the Python frontend — and parser_config rows derived
+// from it — nest the Parser's per-family setups under a "setups" key. Both
+// the DSL defaults and the incoming overrides must be flattened so the
+// stored parser_config carries file families at the top level.
+func TestBuildParserConfig_FlattensNestedParserSetups(t *testing.T) {
+ dsl := map[string]any{
+ "components": map[string]any{
+ "Parser:HipSignsRhyme": map[string]any{
+ "obj": map[string]any{
+ "component_name": "Parser",
+ "params": map[string]any{
+ "outputs": map[string]any{"html": map[string]any{"type": "string"}},
+ "setups": map[string]any{
+ "pdf": map[string]any{"parse_method": "deepdoc", "lang": "Chinese"},
+ "spreadsheet": map[string]any{"parse_method": "deepdoc"},
+ },
+ },
+ },
+ },
+ },
+ }
+ dslJSON, err := json.Marshal(dsl)
+ if err != nil {
+ t.Fatalf("marshal dsl: %v", err)
+ }
+
+ // Legacy nested override, as stored in an upgraded document's parser_config.
+ overrides := map[string]any{
+ "Parser:HipSignsRhyme": map[string]any{
+ "setups": map[string]any{
+ "pdf": map[string]any{"parse_method": "vision"},
+ },
+ },
+ }
+
+ result := BuildParserConfig(dslJSON, overrides)
+ parser, ok := result["Parser:HipSignsRhyme"].(map[string]any)
+ if !ok {
+ t.Fatal("expected Parser:HipSignsRhyme in result")
+ }
+ if _, ok := parser["setups"]; ok {
+ t.Error("nested \"setups\" key must be flattened away")
+ }
+ pdf, ok := parser["pdf"].(map[string]any)
+ if !ok {
+ t.Fatal("expected flattened pdf family in result")
+ }
+ if pdf["parse_method"] != "vision" {
+ t.Errorf("pdf parse_method = %v, want vision from override", pdf["parse_method"])
+ }
+ // BuildParserConfig shallow-merges per top-level key: the override's pdf
+ // family replaces the defaults' pdf family outright (the semantics locked
+ // by TestBuildParserConfig_ShallowMerge_NestedParam).
+ if _, ok := pdf["lang"]; ok {
+ t.Error("pdf lang should not survive: the override family replaces the default family")
+ }
+ // Families the override does not touch keep their DSL defaults.
+ spreadsheet, ok := parser["spreadsheet"].(map[string]any)
+ if !ok {
+ t.Fatal("spreadsheet family from DSL defaults missing")
+ }
+ if spreadsheet["parse_method"] != "deepdoc" {
+ t.Errorf("spreadsheet parse_method = %v, want deepdoc from DSL defaults", spreadsheet["parse_method"])
+ }
+}
+
+// CleanComponentParams must flatten a legacy nested "setups" group before
+// filtering, otherwise the lifted families are dropped as unknown params
+// against the (flat) DSL schema keys.
+func TestCleanComponentParams_FlattensNestedParserSetups(t *testing.T) {
+ dsl := map[string]any{
+ "components": map[string]any{
+ "Parser:HipSignsRhyme": map[string]any{
+ "obj": map[string]any{
+ "component_name": "Parser",
+ "params": map[string]any{
+ "setups": map[string]any{
+ "pdf": map[string]any{"parse_method": "deepdoc"},
+ },
+ },
+ },
+ },
+ },
+ }
+ dslJSON, err := json.Marshal(dsl)
+ if err != nil {
+ t.Fatalf("marshal dsl: %v", err)
+ }
+
+ rawConfig := map[string]any{
+ "Parser:HipSignsRhyme": map[string]any{
+ "setups": map[string]any{
+ "pdf": map[string]any{"parse_method": "vision"},
+ },
+ },
+ }
+
+ result := CleanComponentParams(dslJSON, rawConfig)
+ parser, ok := result["Parser:HipSignsRhyme"].(map[string]any)
+ if !ok {
+ t.Fatal("expected Parser:HipSignsRhyme in result")
+ }
+ if _, ok := parser["setups"]; ok {
+ t.Error("nested \"setups\" key must be flattened away")
+ }
+ pdf, ok := parser["pdf"].(map[string]any)
+ if !ok {
+ t.Fatalf("expected flattened pdf family, got %T", parser["pdf"])
+ }
+ if pdf["parse_method"] != "vision" {
+ t.Errorf("pdf parse_method = %v, want vision", pdf["parse_method"])
+ }
+}
+
+// The runtime passes Doc.ParserConfig as override_params, where top-level
+// keys from the override replace the DSL-baked ones. A legacy nested Parser
+// entry must be lifted BEFORE that merge — otherwise the DSL's flat families
+// win over the user's override once FlattenLegacyParserSetups applies its
+// top-level-wins rule inside NewParserComponent.
+func TestNormalizeParserConfigSetups(t *testing.T) {
+ raw := map[string]any{
+ "Parser:HipSignsRhyme": map[string]any{
+ "setups": map[string]any{
+ "pdf": map[string]any{"parse_method": "vision"},
+ },
+ },
+ "Extractor:AutoExtractDefault": map[string]any{"llm_id": "llm-a"},
+ "metadata": map[string]any{"enabled": true},
+ }
+
+ out := NormalizeParserConfigSetups(raw)
+
+ parser, ok := out["Parser:HipSignsRhyme"].(map[string]any)
+ if !ok {
+ t.Fatal("expected Parser:HipSignsRhyme in result")
+ }
+ if _, ok := parser["setups"]; ok {
+ t.Error("nested \"setups\" key must be flattened away")
+ }
+ pdf, ok := parser["pdf"].(map[string]any)
+ if !ok {
+ t.Fatalf("expected flattened pdf family, got %T", parser["pdf"])
+ }
+ if pdf["parse_method"] != "vision" {
+ t.Errorf("pdf parse_method = %v, want vision", pdf["parse_method"])
+ }
+
+ // Non-Parser entries and dataset-level keys pass through untouched.
+ if got := out["Extractor:AutoExtractDefault"].(map[string]any)["llm_id"]; got != "llm-a" {
+ t.Errorf("extractor llm_id = %v, want llm-a (must not be touched)", got)
+ }
+ if _, ok := out["metadata"].(map[string]any)["enabled"]; !ok {
+ t.Error("dataset-level metadata entry lost")
+ }
+
+ // Flat entries and nil maps are idempotent and nil-safe.
+ flat := NormalizeParserConfigSetups(map[string]any{
+ "Parser:Flat": map[string]any{"pdf": map[string]any{"parse_method": "deepdoc"}},
+ })
+ if _, ok := flat["Parser:Flat"].(map[string]any)["pdf"]; !ok {
+ t.Error("flat Parser entry must pass through unchanged")
+ }
+ if got := NormalizeParserConfigSetups(nil); got != nil {
+ t.Errorf("nil input must return nil, got %v", got)
+ }
+}
+
+// An empty nested "setups" map must still be lifted away: leaving the key in
+// place would create a bogus "setups" file family downstream.
+func TestNormalizeParserConfigSetups_EmptyNestedMap(t *testing.T) {
+ out := NormalizeParserConfigSetups(map[string]any{
+ "Parser:HipSignsRhyme": map[string]any{
+ "setups": map[string]any{},
+ },
+ })
+ parser, ok := out["Parser:HipSignsRhyme"].(map[string]any)
+ if !ok {
+ t.Fatal("expected Parser:HipSignsRhyme in result")
+ }
+ if _, ok := parser["setups"]; ok {
+ t.Error("empty nested \"setups\" key must be removed")
+ }
+}
+
func TestBuildParserConfig_ScalarOverridePreservesOtherDefaults(t *testing.T) {
dslJSON := generalDSL(t)
overrides := map[string]any{
diff --git a/internal/ingestion/task/pipeline_executor.go b/internal/ingestion/task/pipeline_executor.go
index e298cf59ce..a32797dd0a 100644
--- a/internal/ingestion/task/pipeline_executor.go
+++ b/internal/ingestion/task/pipeline_executor.go
@@ -1091,6 +1091,13 @@ func (s *PipelineExecutor) runPipelineWithDSL(ctx context.Context, dsl string) (
// injected in place below without a nil-map assignment panic.
parserConfig = map[string]interface{}{}
}
+ // Legacy parser_config rows saved by the Python-era frontend nest the
+ // Parser's setups under a "setups" key. Lift them BEFORE the runtime
+ // merges this map over the DSL-baked params (override-wins on top-level
+ // key): a nested entry merged as-is would lose to the DSL's flat families
+ // when NewParserComponent applies its own flattening, and the debug page
+ // cap below reads the flat shape too.
+ parserConfig = pipelinepkg.NormalizeParserConfigSetups(parserConfig)
// Surface component params whose cpnID is absent from the DSL. The
// runtime merge (override_params) silently drops such entries;
diff --git a/web/src/utils/__tests__/pipeline-operator.test.ts b/web/src/utils/__tests__/pipeline-operator.test.ts
index a84f51b1d3..b9566b1329 100644
--- a/web/src/utils/__tests__/pipeline-operator.test.ts
+++ b/web/src/utils/__tests__/pipeline-operator.test.ts
@@ -51,6 +51,64 @@ describe('GeneralChunker operator bridge', () => {
});
});
+describe('Parser nested setups compatibility', () => {
+ beforeEach(() => {
+ mockIsGoBackend = true;
+ });
+
+ it('lifts a legacy nested "setups" object into file families', () => {
+ const form = transformApiConfigToForm('Parser', {
+ setups: {
+ pdf: { parse_method: 'vision', pages: [[1, 3]] },
+ },
+ });
+ expect(form.setups).toHaveLength(1);
+ expect(form.setups[0].fileFormat).toBe('pdf');
+ expect(form.setups[0].parse_method).toBe('vision');
+ expect(form.setups[0].pages).toEqual([{ from: 1, to: 3 }]);
+ });
+
+ it('keeps flat file families unchanged', () => {
+ const form = transformApiConfigToForm('Parser', {
+ pdf: { parse_method: 'deepdoc' },
+ });
+ expect(form.setups).toHaveLength(1);
+ expect(form.setups[0].fileFormat).toBe('pdf');
+ expect(form.setups[0].parse_method).toBe('deepdoc');
+ });
+
+ it('skips non-family keys such as outputs', () => {
+ const form = transformApiConfigToForm('Parser', {
+ outputs: { html: { type: 'string' } },
+ pdf: { parse_method: 'deepdoc' },
+ });
+ const families = form.setups.map((s: any) => s.fileFormat);
+ expect(families).toEqual(['pdf']);
+ });
+
+ it('does not surface "setups" as a file family in buildOperatorNode', () => {
+ const node = buildOperatorNode(
+ {
+ id: 'Parser:HipSignsRhyme',
+ data: {
+ form: { setups: [{ fileFormat: 'pdf', parse_method: 'naive' }] },
+ },
+ } as any,
+ {
+ 'Parser:HipSignsRhyme': {
+ setups: { pdf: { parse_method: 'vision' } },
+ },
+ },
+ );
+
+ const form = (node.data as Record<string, any>).form;
+ const families = form.setups.map((s: any) => s.fileFormat);
+ expect(families).not.toContain('setups');
+ const pdf = form.setups.find((s: any) => s.fileFormat === 'pdf');
+ expect(pdf?.parse_method).toBe('vision');
+ });
+});
+
describe('buildOperatorNode dataset-level metadata precedence', () => {
beforeEach(() => {
mockIsGoBackend = true;
diff --git a/web/src/utils/pipeline-operator.ts b/web/src/utils/pipeline-operator.ts
index a956481b2f..880b409efd 100644
--- a/web/src/utils/pipeline-operator.ts
+++ b/web/src/utils/pipeline-operator.ts
@@ -63,7 +63,18 @@ export function transformParserConfigSetups(
return [];
}
- return Object.entries(setups)
+ // parser_config entries saved by the Python-era frontend (or derived from
+ // a Python canvas) nest the per-family setups under a "setups" key; the Go
+ // shape lists file families at the top level. Lift the nested group —
+ // top-level families win — and drop the non-family protocol keys so they
+ // never render as a bogus file format.
+ let source = setups;
+ const nested = source.setups;
+ if (nested && typeof nested === 'object' && !Array.isArray(nested)) {
+ source = { ...nested, ...omit(source, ['setups']) };
+ }
+
+ return Object.entries(omit(source, ['outputs', 'allowed_output_format']))
.map(([fileFormat, config]) => {
const { pages, ...rest } = (config ?? {}) as Record<string, any>;
const normalizedPages = Array.isArray(pages)