Skip to content

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

Fix: The general parsing method for legacy data at the file level fails to display. (#20794)

balibabuad7f2c3874d9
diff --git a/web/src/components/document-pipeline-dialog/index.tsx b/web/src/components/document-pipeline-dialog/index.tsx
index 728c458676..9beb5d5a75 100644
--- a/web/src/components/document-pipeline-dialog/index.tsx
+++ b/web/src/components/document-pipeline-dialog/index.tsx
@@ -31,10 +31,7 @@ import { IChangeParserRequestBody } from '@/interfaces/request/document';
import { useCallback } from 'react';
import { FieldErrors, useFormState, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
-import {
- buildParserOptionValue,
- ParserOptionKind,
-} from '@/hooks/use-parser-options';
+import { buildParserSelectValue } from '@/hooks/use-parser-options';
import { useParserSelectHandler } from '@/hooks/use-parser-select-handler';
import {
IDocumentPipelineDialogProps,
@@ -129,19 +126,11 @@ export function DocumentPipelineDialog({
render={() => (
<FormItem>
<ParserSelect
- value={
- parseType === ParseType.BuiltIn
- ? buildParserOptionValue(
- ParserOptionKind.BuiltIn,
- selectedParserId,
- )
- : selectedPipelineId
- ? buildParserOptionValue(
- ParserOptionKind.Pipeline,
- selectedPipelineId,
- )
- : undefined
- }
+ value={buildParserSelectValue({
+ parseType,
+ parserId: selectedParserId,
+ pipelineId: selectedPipelineId,
+ })}
onChange={handleParserSelect}
/>
<FormMessage />
diff --git a/web/src/hooks/use-parser-options.test.ts b/web/src/hooks/use-parser-options.test.ts
index 43e508d999..c5e000dcbb 100644
--- a/web/src/hooks/use-parser-options.test.ts
+++ b/web/src/hooks/use-parser-options.test.ts
@@ -1,9 +1,12 @@
import { renderHook } from '@testing-library/react';
+import { ParseType } from '@/constants/knowledge';
import { AgentListItemType } from '@/interfaces/database/agent';
import {
buildParserOptionValue,
+ buildParserSelectValue,
parseParserOptionValue,
ParserOptionKind,
+ resolveBuiltinParserId,
useParserOptions,
} from '@/hooks/use-parser-options';
@@ -81,6 +84,55 @@ describe('parser option value encoding', () => {
});
});
+describe('resolveBuiltinParserId', () => {
+ it('maps legacy builtin ids to their current id', () => {
+ expect(resolveBuiltinParserId('naive')).toBe('general');
+ });
+
+ it('passes through current and unknown ids unchanged', () => {
+ expect(resolveBuiltinParserId('general')).toBe('general');
+ expect(resolveBuiltinParserId('book')).toBe('book');
+ expect(resolveBuiltinParserId('')).toBe('');
+ });
+});
+
+describe('buildParserSelectValue', () => {
+ it('resolves legacy builtin ids so old saved values match an option', () => {
+ expect(
+ buildParserSelectValue({
+ parseType: ParseType.BuiltIn,
+ parserId: 'naive',
+ }),
+ ).toBe('builtin:general');
+ });
+
+ it('builds the value from the id of the active parse type', () => {
+ expect(
+ buildParserSelectValue({
+ parseType: ParseType.BuiltIn,
+ parserId: 'book',
+ pipelineId: 'pipe-1',
+ }),
+ ).toBe('builtin:book');
+ expect(
+ buildParserSelectValue({
+ parseType: ParseType.Pipeline,
+ parserId: 'book',
+ pipelineId: 'pipe-1',
+ }),
+ ).toBe('pipeline:pipe-1');
+ });
+
+ it('returns undefined when the active id is empty', () => {
+ expect(
+ buildParserSelectValue({ parseType: ParseType.BuiltIn, parserId: '' }),
+ ).toBeUndefined();
+ expect(
+ buildParserSelectValue({ parseType: ParseType.Pipeline }),
+ ).toBeUndefined();
+ });
+});
+
describe('useParserOptions merged list', () => {
it('puts pipeline options first, then builtin options with plain labels', () => {
agentRequest.useFetchBuiltinPipelines.mockReturnValue({
diff --git a/web/src/hooks/use-parser-options.ts b/web/src/hooks/use-parser-options.ts
index b9ba9c7e38..db1a9efcef 100644
--- a/web/src/hooks/use-parser-options.ts
+++ b/web/src/hooks/use-parser-options.ts
@@ -1,4 +1,5 @@
import { AgentCategory } from '@/constants/agent';
+import { ParseType } from '@/constants/knowledge';
import { AgentListItemType } from '@/interfaces/database/agent';
import {
useFetchAgentList,
@@ -39,6 +40,46 @@ export function parseParserOptionValue(value?: string): {
return null;
}
+// Builtin parser ids saved by older versions, mapped to the id the current
+// builtin pipeline catalog uses. The Go backend resolves the same aliases at
+// lookup time (internal/ingestion/pipeline/builtin_registry.go); the select
+// needs them too, otherwise a saved parser_id like "naive" matches no option
+// and renders as unavailable.
+const LegacyBuiltinParserAliases: Record<string, string> = {
+ naive: 'general',
+};
+
+export function resolveBuiltinParserId(rawId: string) {
+ return LegacyBuiltinParserAliases[rawId] ?? rawId;
+}
+
+// buildParserSelectValue derives the ParserSelect value from the form's
+// parse_type / parser_id / pipeline_id triple. Builtin ids pass through the
+// legacy alias map so old saved values keep matching an option. An empty id
+// yields undefined so the select shows its placeholder instead of a dangling
+// "kind:" value.
+export function buildParserSelectValue({
+ parseType,
+ parserId,
+ pipelineId,
+}: {
+ parseType?: ParseType;
+ parserId?: string;
+ pipelineId?: string;
+}): string | undefined {
+ if (parseType === ParseType.BuiltIn) {
+ return parserId
+ ? buildParserOptionValue(
+ ParserOptionKind.BuiltIn,
+ resolveBuiltinParserId(parserId),
+ )
+ : undefined;
+ }
+ return pipelineId
+ ? buildParserOptionValue(ParserOptionKind.Pipeline, pipelineId)
+ : undefined;
+}
+
// useParserOptions returns the unified list of parser options shown in the
// merged dataset/document parser dropdown: pipeline (canvas) options first,
// followed by builtin options. Builtin options carry their plain label; the
diff --git a/web/src/pages/dataset/setting/index.tsx b/web/src/pages/dataset/setting/index.tsx
index 88e38c53c7..8c60be5166 100644
--- a/web/src/pages/dataset/setting/index.tsx
+++ b/web/src/pages/dataset/setting/index.tsx
@@ -17,10 +17,7 @@ import {
FormMessage,
} from '@/components/ui/form';
import { ParseType } from '@/constants/knowledge';
-import {
- buildParserOptionValue,
- ParserOptionKind,
-} from '@/hooks/use-parser-options';
+import { buildParserSelectValue } from '@/hooks/use-parser-options';
import { useParserSelectHandler } from '@/hooks/use-parser-select-handler';
import {
useActiveTab,
@@ -241,19 +238,11 @@ export default function DatasetSetting() {
render={() => (
<FormItem className="space-y-1">
<ParserSelect
- value={
- parseType === ParseType.BuiltIn
- ? buildParserOptionValue(
- ParserOptionKind.BuiltIn,
- builtinPipelineId ?? '',
- )
- : pipelineId
- ? buildParserOptionValue(
- ParserOptionKind.Pipeline,
- pipelineId,
- )
- : undefined
- }
+ value={buildParserSelectValue({
+ parseType,
+ parserId: builtinPipelineId,
+ pipelineId,
+ })}
onChange={handleParserSelect}
/>
<FormMessage />
diff --git a/web/src/pages/datasets/dataset-creating-dialog.tsx b/web/src/pages/datasets/dataset-creating-dialog.tsx
index dd7f8fda28..1b3b739f35 100644
--- a/web/src/pages/datasets/dataset-creating-dialog.tsx
+++ b/web/src/pages/datasets/dataset-creating-dialog.tsx
@@ -18,10 +18,7 @@ import {
} from '@/components/ui/form';
import { Input } from '@/components/ui/input';
import { ParseType } from '@/constants/knowledge';
-import {
- buildParserOptionValue,
- ParserOptionKind,
-} from '@/hooks/use-parser-options';
+import { buildParserSelectValue } from '@/hooks/use-parser-options';
import { useParserSelectHandler } from '@/hooks/use-parser-select-handler';
import { useFetchDefaultModelDictionary } from '@/hooks/use-llm-request';
import { IModalProps } from '@/interfaces/common';
@@ -151,19 +148,11 @@ export function InputForm({ onOk }: IModalProps<any>) {
render={() => (
<FormItem>
<ParserSelect
- value={
- parseType === ParseType.BuiltIn
- ? buildParserOptionValue(
- ParserOptionKind.BuiltIn,
- parserId ?? '',
- )
- : pipelineId
- ? buildParserOptionValue(
- ParserOptionKind.Pipeline,
- pipelineId,
- )
- : undefined
- }
+ value={buildParserSelectValue({
+ parseType,
+ parserId,
+ pipelineId,
+ })}
onChange={handleParserSelect}
/>
<FormMessage />