Skip to content

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

Feat: There should be a notification at the file level when a pipeline is deleted. (#21765)

balibabu5a1a6ec8d461
diff --git a/web/src/components/parser-tree-select/index.tsx b/web/src/components/parser-tree-select/index.tsx
index eefe7e5a87..2317fa7097 100644
--- a/web/src/components/parser-tree-select/index.tsx
+++ b/web/src/components/parser-tree-select/index.tsx
@@ -4,9 +4,10 @@ import {
ParserOptionKind,
} from '@/hooks/use-parser-options';
import { cn } from '@/lib/utils';
-import { AlertCircle, TriangleAlert } from 'lucide-react';
+import { AlertCircle } from 'lucide-react';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
+import { ParserUnavailableLabel } from '../parser-unavailable-label';
import { PipelineVersionLabel } from '../pipeline-version-label';
import { TreeSelect, TreeSelectNode } from '../tree-select';
import { useParserTreeData } from './use-parser-tree-data';
@@ -102,19 +103,7 @@ export function ParserTreeSelect({
// (e.g. a deleted pipeline or pruned version) and options have finished
// loading, render a localized "unavailable" label instead of the raw
// internal value.
- const renderMissingParser = useCallback(
- () => (
- <span className="flex items-center gap-1.5">
- <TriangleAlert className="size-4 flex-shrink-0" />
- <span className="truncate">
- {t('knowledgeConfiguration.parserOptionUnavailable', {
- defaultValue: 'unavailable',
- })}
- </span>
- </span>
- ),
- [t],
- );
+ const renderMissingParser = useCallback(() => <ParserUnavailableLabel />, []);
// The outdated icon is a pure hint. The Radix tooltip trigger renders a
// raw <button> with no `type`, which inside the surrounding forms (dataset
diff --git a/web/src/components/parser-unavailable-label.tsx b/web/src/components/parser-unavailable-label.tsx
new file mode 100644
index 0000000000..0c2d233455
--- /dev/null
+++ b/web/src/components/parser-unavailable-label.tsx
@@ -0,0 +1,20 @@
+import { cn } from '@/lib/utils';
+import { TriangleAlert } from 'lucide-react';
+import { useTranslation } from 'react-i18next';
+
+// Shared "unavailable" label for a saved parser binding whose pipeline or
+// pinned version was deleted: ParserTreeSelect renders it for a missing
+// select value, the dataset file row for a document that can no longer parse.
+// The text color comes from the caller (TreeSelect's trigger paints a missing
+// value with text-text-secondary on its own).
+export function ParserUnavailableLabel({ className }: { className?: string }) {
+ const { t } = useTranslation();
+ return (
+ <span className={cn('flex items-center gap-1.5', className)}>
+ <TriangleAlert className="size-4 flex-shrink-0" />
+ <span className="truncate">
+ {t('knowledgeConfiguration.parserOptionUnavailable')}
+ </span>
+ </span>
+ );
+}
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index 777fb5fe8d..383b839123 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -402,6 +402,9 @@ Example: A 1 KB message with 1024-dim embedding uses ~9 KB. The 5 MB default lim
},
knowledgeDetails: {
continueUpload: 'Continue upload',
+ uploadPipelineDeletedTitle: 'Parsing pipeline unavailable',
+ uploadPipelineDeletedContent:
+ 'The pipeline configured for this dataset has been deleted or has no published version, so uploaded files cannot be parsed automatically. Reconfigure a pipeline in the dataset settings, or upload now and configure parsing for each file individually.',
reselectParser: 'Reselect parse method',
goAddModel: 'Go add model',
uploadMissingModelsTitle: 'Some files lack a required model',
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 2330e3092a..2c08e8ccaa 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -359,6 +359,9 @@ export default {
},
knowledgeDetails: {
continueUpload: '继续上传',
+ uploadPipelineDeletedTitle: '解析 Pipeline 不可用',
+ uploadPipelineDeletedContent:
+ '该数据集配置的解析 Pipeline 已被删除或没有已发布版本,无法在上传时自动解析。请在数据集设置中重新配置 Pipeline,或继续上传后为文件单独配置解析方式。',
reselectParser: '重新选择解析方法',
goAddModel: '前往添加模型',
uploadMissingModelsTitle: '部分文件缺少解析所需的模型',
diff --git a/web/src/pages/dataset/dataset/index.tsx b/web/src/pages/dataset/dataset/index.tsx
index bb6338b99d..3164bec6e7 100644
--- a/web/src/pages/dataset/dataset/index.tsx
+++ b/web/src/pages/dataset/dataset/index.tsx
@@ -36,14 +36,14 @@ import { useHandleUploadDocument } from './use-upload-document';
export default function Dataset() {
const { t } = useTranslation();
+ const { knowledgeBase } = useKnowledgeBaseContext();
const {
documentUploadVisible,
hideDocumentUploadModal,
showDocumentUploadModal,
onDocumentUploadOk,
documentUploadLoading,
- } = useHandleUploadDocument();
- const { knowledgeBase } = useKnowledgeBaseContext();
+ } = useHandleUploadDocument(knowledgeBase?.pipeline_id);
const {
searchString,
documents,
diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
index e30708e705..f69a40598a 100644
--- a/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
+++ b/web/src/pages/dataset/dataset/parsing-status-cell.test.tsx
@@ -12,6 +12,7 @@ jest.mock('./reparse-dialog', () => ({
const mockRunDocumentByIds = jest.fn();
const mockShowReparseDialog = jest.fn();
const mockUseDocumentPipelineVersion = jest.fn();
+const mockWarning = jest.fn();
jest.mock('./use-run-document', () => ({
useHandleRunDocumentByIds: () => ({
@@ -27,6 +28,11 @@ jest.mock('./use-document-pipeline-version', () => ({
mockUseDocumentPipelineVersion(record),
}));
+jest.mock('@/components/ui/message', () => ({
+ __esModule: true,
+ default: { warning: (msg: string) => mockWarning(msg) },
+}));
+
import { IngestionTaskStatus } from './constant';
import { ParseDropdownButton, ParsingStatusCell } from './parsing-status-cell';
import { TooltipProvider } from '@/components/ui/tooltip';
@@ -90,8 +96,12 @@ describe('ParsingStatusCell', () => {
beforeEach(() => {
mockRunDocumentByIds.mockClear();
mockShowReparseDialog.mockClear();
+ mockWarning.mockClear();
mockUseDocumentPipelineVersion.mockReset();
- mockUseDocumentPipelineVersion.mockReturnValue(undefined);
+ mockUseDocumentPipelineVersion.mockReturnValue({
+ version: undefined,
+ missing: false,
+ });
});
it('shows the queued chip for CREATED tasks', () => {
@@ -218,9 +228,12 @@ describe('ParsingStatusCell', () => {
it('labels a pipeline document by its version title and alias', () => {
mockUseDocumentPipelineVersion.mockReturnValue({
- id: 'v1',
- title: 'geek pipeline 2026-10-29 11:47:29',
- alias: '111',
+ version: {
+ id: 'v1',
+ title: 'geek pipeline 2026-10-29 11:47:29',
+ alias: '111',
+ },
+ missing: false,
});
renderDropdown({
pipeline_id: 'canvas-1',
@@ -271,4 +284,77 @@ describe('ParsingStatusCell', () => {
renderDropdown({ pipeline_id: '', pipeline_version_outdated: false });
expect(screen.queryByText('!')).not.toBeInTheDocument();
});
+
+ it('shows the unavailable display when the bound pipeline version was deleted', () => {
+ mockUseDocumentPipelineVersion.mockReturnValue({
+ version: undefined,
+ missing: true,
+ });
+ renderDropdown({
+ pipeline_id: 'canvas-1',
+ pipeline_name: 'My pipeline',
+ pipeline_version_id: 'v1',
+ });
+
+ expect(
+ screen.getByText('knowledgeConfiguration.parserOptionUnavailable'),
+ ).toBeInTheDocument();
+ expect(screen.queryByText('My pipeline')).not.toBeInTheDocument();
+ });
+
+ // A deleted pin is the stronger signal, so the outdated bang stays hidden
+ // while the binding is missing (same precedence as ParserTreeSelect).
+ it('hides the outdated bang while the binding is missing', () => {
+ mockUseDocumentPipelineVersion.mockReturnValue({
+ version: undefined,
+ missing: true,
+ });
+ renderDropdown({
+ pipeline_id: 'canvas-1',
+ pipeline_version_id: 'v1',
+ pipeline_version_outdated: true,
+ });
+
+ expect(screen.queryByText('!')).not.toBeInTheDocument();
+ });
+
+ it('warns and blocks parsing when the bound pipeline version was deleted', () => {
+ mockUseDocumentPipelineVersion.mockReturnValue({
+ version: undefined,
+ missing: true,
+ });
+ renderCell({
+ pipeline_id: 'canvas-1',
+ pipeline_version_id: 'v1',
+ ingestion_status: IngestionTaskStatus.COMPLETED,
+ chunk_count: 3,
+ });
+
+ fireEvent.click(screen.getByTestId('document-parse-toggle'));
+
+ expect(mockWarning).toHaveBeenCalledWith(
+ 'knowledgeConfiguration.parserOptionUnavailableMessage',
+ );
+ expect(mockRunDocumentByIds).not.toHaveBeenCalled();
+ expect(mockShowReparseDialog).not.toHaveBeenCalled();
+ });
+
+ // Cancelling never touches the pipeline, so a missing binding must not
+ // block stopping a running parse.
+ it('still cancels a running parse when the binding is missing', () => {
+ mockUseDocumentPipelineVersion.mockReturnValue({
+ version: undefined,
+ missing: true,
+ });
+ renderCell({
+ pipeline_id: 'canvas-1',
+ pipeline_version_id: 'v1',
+ ingestion_status: IngestionTaskStatus.RUNNING,
+ });
+
+ fireEvent.click(screen.getByTestId('document-parse-toggle'));
+
+ expect(mockWarning).not.toHaveBeenCalled();
+ expect(mockRunDocumentByIds).toHaveBeenCalledTimes(1);
+ });
});
diff --git a/web/src/pages/dataset/dataset/parsing-status-cell.tsx b/web/src/pages/dataset/dataset/parsing-status-cell.tsx
index 0b50735588..ea47b338a6 100644
--- a/web/src/pages/dataset/dataset/parsing-status-cell.tsx
+++ b/web/src/pages/dataset/dataset/parsing-status-cell.tsx
@@ -1,6 +1,8 @@
import { IconFontFill } from '@/components/icon-font';
+import { ParserUnavailableLabel } from '@/components/parser-unavailable-label';
import { PipelineVersionLabel } from '@/components/pipeline-version-label';
import { Button } from '@/components/ui/button';
+import message from '@/components/ui/message';
import {
DropdownMenu,
DropdownMenuContent,
@@ -9,11 +11,6 @@ import {
} from '@/components/ui/dropdown-menu';
import { Progress } from '@/components/ui/progress';
import { Separator } from '@/components/ui/separator';
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from '@/components/ui/tooltip';
import { RAGFlowTooltip } from '@/components/ui/tooltip';
import { IDocumentInfo } from '@/interfaces/database/document';
import { cn } from '@/lib/utils';
@@ -76,7 +73,8 @@ export function ParseDropdownButton({
} & UseChangeDocumentParserShowType) {
const { t } = useTranslation();
const parserLabel = getDocumentParserLabel(record);
- const version = useDocumentPipelineVersion(record);
+ const { version, missing: parserMissing } =
+ useDocumentPipelineVersion(record);
const isPipeline = !!record.pipeline_id;
const handleShowChangeParserModal = useCallback(() => {
@@ -85,42 +83,45 @@ export function ParseDropdownButton({
// Pipeline documents are labeled by the version they parse with — the
// version title plus its alias as secondary text, the same display the
- // parser tree select uses. While the version list is still loading, or when
- // the pinned version is gone, fall back to the pipeline name. Built-in
- // parsers keep the plain parser label.
+ // parser tree select uses. While the version list is still loading, fall
+ // back to the pipeline name. A binding whose pipeline or pinned version was
+ // deleted renders the same "unavailable" display as ParserTreeSelect's
+ // missing value, with the reason on hover. Built-in parsers keep the plain
+ // parser label.
const versionTitle = version?.title ?? parserLabel;
+ const tooltipContent = parserMissing ? (
+ <p>{t('knowledgeConfiguration.parserOptionUnavailableMessage')}</p>
+ ) : isPipeline ? (
+ <div>
+ <p>{versionTitle}</p>
+ {version?.alias ? <p>{version.alias}</p> : null}
+ </div>
+ ) : (
+ <p>{parserLabel}</p>
+ );
+
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<div className="flex items-center gap-1">
- <Tooltip>
- <TooltipTrigger asChild>
- <Button variant="static" size="auto">
- {isPipeline ? (
- <PipelineVersionLabel
- title={versionTitle}
- alias={version?.alias}
- className="max-w-72"
- aliasClassName="max-w-[50%]"
- />
- ) : (
- parserLabel
- )}
- </Button>
- </TooltipTrigger>
- <TooltipContent>
- {isPipeline ? (
- <div>
- <p>{versionTitle}</p>
- {version?.alias ? <p>{version.alias}</p> : null}
- </div>
+ <RAGFlowTooltip asChild tooltip={tooltipContent}>
+ <Button variant="static" size="auto">
+ {parserMissing ? (
+ <ParserUnavailableLabel className="text-text-secondary" />
+ ) : isPipeline ? (
+ <PipelineVersionLabel
+ title={versionTitle}
+ alias={version?.alias}
+ className="max-w-72"
+ aliasClassName="max-w-[50%]"
+ />
) : (
- <p>{parserLabel}</p>
+ parserLabel
)}
- </TooltipContent>
- </Tooltip>
- {record.pipeline_version_outdated ? (
+ </Button>
+ </RAGFlowTooltip>
+ {record.pipeline_version_outdated && !parserMissing ? (
<RAGFlowTooltip tooltip={t('flow.version.outdated')}>
<span className="text-destructive cursor-help font-bold">!</span>
</RAGFlowTooltip>
@@ -161,6 +162,7 @@ export function ParsingStatusCell({
const isQueued = effectiveRun === RunningStatus.QUEUED;
const isStopping = isDocumentStopping(record);
const isZeroChunk = chunk_count === 0;
+ const { missing: parserMissing } = useDocumentPipelineVersion(record);
const handleOperationIconClick = (option?: {
delete: boolean;
@@ -175,6 +177,16 @@ export function ParsingStatusCell({
const needsParseConfirm = !isRunning && !isZeroChunk;
const handleParseClick = () => {
+ // A document whose pipeline or pinned version was deleted can no longer
+ // parse — warn and keep the run request from firing (and the reparse
+ // confirmation from opening). Cancelling a running parse stays allowed:
+ // it never touches the pipeline.
+ if (!isRunning && parserMissing) {
+ message.warning(
+ t('knowledgeConfiguration.parserOptionUnavailableMessage'),
+ );
+ return;
+ }
if (needsParseConfirm) {
showReparseDialogModal();
return;
diff --git a/web/src/pages/dataset/dataset/use-dataset-pipeline-missing.test.ts b/web/src/pages/dataset/dataset/use-dataset-pipeline-missing.test.ts
new file mode 100644
index 0000000000..6d3e5c519a
--- /dev/null
+++ b/web/src/pages/dataset/dataset/use-dataset-pipeline-missing.test.ts
@@ -0,0 +1,80 @@
+import { renderHook } from '@testing-library/react';
+
+const mockUseFetchCanvasVersionList = jest.fn();
+
+jest.mock('@/hooks/use-agent-request', () => ({
+ useFetchCanvasVersionList: (canvasId?: string) =>
+ mockUseFetchCanvasVersionList(canvasId),
+}));
+
+import { useDatasetPipelineMissing } from './use-dataset-pipeline-missing';
+
+const versions = [{ id: 'v1', title: 'newest', created_at: '2026-10-29' }];
+
+describe('useDatasetPipelineMissing', () => {
+ beforeEach(() => {
+ mockUseFetchCanvasVersionList.mockReset();
+ // Mirrors useFetchCanvasVersionList: a disabled query (no canvas id)
+ // never produces data.
+ mockUseFetchCanvasVersionList.mockImplementation((canvasId?: string) => ({
+ data: canvasId ? versions : undefined,
+ loading: false,
+ isError: false,
+ }));
+ });
+
+ it('stays quiet before the dataset configuration has loaded', () => {
+ const { result } = renderHook(() => useDatasetPipelineMissing(undefined));
+
+ expect(mockUseFetchCanvasVersionList).toHaveBeenCalledWith(undefined);
+ expect(result.current).toBe(false);
+ });
+
+ it('stays disabled for built-in parser datasets', () => {
+ const { result } = renderHook(() => useDatasetPipelineMissing(''));
+
+ expect(mockUseFetchCanvasVersionList).toHaveBeenCalledWith('');
+ expect(result.current).toBe(false);
+ });
+
+ it('stays quiet while the version list is in flight', () => {
+ mockUseFetchCanvasVersionList.mockReturnValue({
+ data: undefined,
+ loading: true,
+ isError: false,
+ });
+ const { result } = renderHook(() => useDatasetPipelineMissing('canvas-1'));
+
+ expect(result.current).toBe(false);
+ });
+
+ it('flags a pipeline whose version list failed to load (deleted pipeline)', () => {
+ mockUseFetchCanvasVersionList.mockReturnValue({
+ data: undefined,
+ loading: false,
+ isError: true,
+ });
+ const { result } = renderHook(() =>
+ useDatasetPipelineMissing('deleted-canvas'),
+ );
+
+ expect(result.current).toBe(true);
+ });
+
+ it('flags a pipeline with no published versions left', () => {
+ mockUseFetchCanvasVersionList.mockReturnValue({
+ data: [],
+ loading: false,
+ isError: false,
+ });
+ const { result } = renderHook(() => useDatasetPipelineMissing('canvas-1'));
+
+ expect(result.current).toBe(true);
+ });
+
+ it('stays available while any published version exists', () => {
+ const { result } = renderHook(() => useDatasetPipelineMissing('canvas-1'));
+
+ expect(result.current).toBe(false);
+ });
+});
diff --git a/web/src/pages/dataset/dataset/use-dataset-pipeline-missing.ts b/web/src/pages/dataset/dataset/use-dataset-pipeline-missing.ts
new file mode 100644
index 0000000000..e0ccc2b066
--- /dev/null
+++ b/web/src/pages/dataset/dataset/use-dataset-pipeline-missing.ts
@@ -0,0 +1,22 @@
+import { useFetchCanvasVersionList } from '@/hooks/use-agent-request';
+
+// Flags a dataset whose configured pipeline can no longer parse: the version
+// list failed to load (the pipeline was deleted or is no longer visible), or
+// it loaded empty (no published versions left). Unlike the document-level
+// hook there is no pinned version here — any published version keeps the
+// dataset parseable. While the list is in flight (or the query is disabled
+// because the dataset has not loaded yet) the verdict stays false so the
+// upload dialog never warns spuriously.
+export const useDatasetPipelineMissing = (pipelineId?: string) => {
+ const {
+ data: versions,
+ loading,
+ isError,
+ } = useFetchCanvasVersionList(pipelineId);
+
+ const missing =
+ !!pipelineId &&
+ (isError || (!loading && !!versions && versions.length === 0));
+
+ return missing;
+};
diff --git a/web/src/pages/dataset/dataset/use-document-pipeline-version.test.ts b/web/src/pages/dataset/dataset/use-document-pipeline-version.test.ts
index 0817b92457..566352bc96 100644
--- a/web/src/pages/dataset/dataset/use-document-pipeline-version.test.ts
+++ b/web/src/pages/dataset/dataset/use-document-pipeline-version.test.ts
@@ -21,6 +21,8 @@ describe('useDocumentPipelineVersion', () => {
// never produces data.
mockUseFetchCanvasVersionList.mockImplementation((canvasId?: string) => ({
data: canvasId ? versions : undefined,
+ loading: false,
+ isError: false,
}));
});
@@ -33,8 +35,9 @@ describe('useDocumentPipelineVersion', () => {
);
expect(mockUseFetchCanvasVersionList).toHaveBeenCalledWith('canvas-1');
- expect(result.current?.id).toBe('v1');
- expect(result.current?.alias).toBe('111');
+ expect(result.current.version?.id).toBe('v1');
+ expect(result.current.version?.alias).toBe('111');
+ expect(result.current.missing).toBe(false);
});
it('tracks the latest version when nothing is pinned', () => {
@@ -45,10 +48,11 @@ describe('useDocumentPipelineVersion', () => {
}),
);
- expect(result.current?.id).toBe('v2');
+ expect(result.current.version?.id).toBe('v2');
+ expect(result.current.missing).toBe(false);
});
- it('resolves to undefined when the pinned version is gone', () => {
+ it('flags a pinned version that no longer exists as missing', () => {
const { result } = renderHook(() =>
useDocumentPipelineVersion({
pipeline_id: 'canvas-1',
@@ -56,7 +60,58 @@ describe('useDocumentPipelineVersion', () => {
}),
);
- expect(result.current).toBeUndefined();
+ expect(result.current.version).toBeUndefined();
+ expect(result.current.missing).toBe(true);
+ });
+
+ it('flags an unpinned binding whose pipeline has no published versions left', () => {
+ mockUseFetchCanvasVersionList.mockReturnValue({
+ data: [],
+ loading: false,
+ isError: false,
+ });
+ const { result } = renderHook(() =>
+ useDocumentPipelineVersion({
+ pipeline_id: 'canvas-1',
+ pipeline_version_id: '',
+ }),
+ );
+
+ expect(result.current.version).toBeUndefined();
+ expect(result.current.missing).toBe(true);
+ });
+
+ it('flags a pipeline whose version list failed to load (deleted pipeline)', () => {
+ mockUseFetchCanvasVersionList.mockReturnValue({
+ data: undefined,
+ loading: false,
+ isError: true,
+ });
+ const { result } = renderHook(() =>
+ useDocumentPipelineVersion({
+ pipeline_id: 'deleted-canvas',
+ pipeline_version_id: 'v1',
+ }),
+ );
+
+ expect(result.current.missing).toBe(true);
+ });
+
+ it('stays quiet while the version list is in flight', () => {
+ mockUseFetchCanvasVersionList.mockReturnValue({
+ data: undefined,
+ loading: true,
+ isError: false,
+ });
+ const { result } = renderHook(() =>
+ useDocumentPipelineVersion({
+ pipeline_id: 'canvas-1',
+ pipeline_version_id: 'v1',
+ }),
+ );
+
+ expect(result.current.version).toBeUndefined();
+ expect(result.current.missing).toBe(false);
});
it('stays disabled for built-in parser documents', () => {
@@ -68,6 +123,7 @@ describe('useDocumentPipelineVersion', () => {
);
expect(mockUseFetchCanvasVersionList).toHaveBeenCalledWith(undefined);
- expect(result.current).toBeUndefined();
+ expect(result.current.version).toBeUndefined();
+ expect(result.current.missing).toBe(false);
});
});
diff --git a/web/src/pages/dataset/dataset/use-document-pipeline-version.ts b/web/src/pages/dataset/dataset/use-document-pipeline-version.ts
index c6de7d2431..b7d45935a0 100644
--- a/web/src/pages/dataset/dataset/use-document-pipeline-version.ts
+++ b/web/src/pages/dataset/dataset/use-document-pipeline-version.ts
@@ -5,16 +5,30 @@ import { IDocumentInfo } from '@/interfaces/database/document';
// column can show the version title/alias instead of the pipeline name. The
// version list query is keyed by canvas id, so rows sharing a pipeline share
// one fetch. A document without a pinned version tracks the latest published
-// version (the list is newest-first); a pinned version that no longer exists
-// resolves to undefined and the caller falls back to the pipeline name.
+// version (the list is newest-first).
+//
+// `missing` flags a pipeline binding that can no longer parse: the version
+// list failed to load (the pipeline was deleted or is no longer visible), or
+// it loaded without the version the document parses with (a deleted pinned
+// version, or an unpinned binding whose pipeline has no published versions
+// left). While the list is in flight the verdict stays false so the row never
+// flashes "unavailable" on mount or refetch. Built-in parser documents are
+// never missing.
export const useDocumentPipelineVersion = (
record: Pick<IDocumentInfo, 'pipeline_id' | 'pipeline_version_id'>,
) => {
- const { data: versions } = useFetchCanvasVersionList(
- record.pipeline_id || undefined,
- );
+ const {
+ data: versions,
+ loading,
+ isError,
+ } = useFetchCanvasVersionList(record.pipeline_id || undefined);
- return record.pipeline_version_id
+ const version = record.pipeline_version_id
? versions?.find((item) => item.id === record.pipeline_version_id)
: versions?.[0];
+
+ const missing =
+ !!record.pipeline_id && (isError || (!loading && !!versions && !version));
+
+ return { version, missing };
};
diff --git a/web/src/pages/dataset/dataset/use-upload-document.test.ts b/web/src/pages/dataset/dataset/use-upload-document.test.ts
index 555e9258c7..a93406079b 100644
--- a/web/src/pages/dataset/dataset/use-upload-document.test.ts
+++ b/web/src/pages/dataset/dataset/use-upload-document.test.ts
@@ -21,6 +21,14 @@ const mockWarning = jest.fn();
// which documents the hook auto-parses.
let mockUploadGaps: Array<Record<string, unknown>> = [];
let mockDocumentGaps: Record<string, Array<Record<string, unknown>>> = {};
+let mockPipelineMissing = false;
+// The warning mock auto-confirms by default so the pre-existing gap tests
+// keep flowing into the upload; cancellation tests flip this off.
+let mockAutoConfirmWarning = true;
+
+jest.mock('./use-dataset-pipeline-missing', () => ({
+ useDatasetPipelineMissing: () => mockPipelineMissing,
+}));
jest.mock('@/hooks/use-document-request', () => ({
useUploadDocument: () => ({ uploadDocument: mockUpload, loading: false }),
@@ -40,7 +48,9 @@ jest.mock('@/components/ui/modal/modal', () => ({
Modal: {
warning: (options: { onOk?: () => void }) => {
mockWarning(options);
- options.onOk?.();
+ if (mockAutoConfirmWarning) {
+ options.onOk?.();
+ }
},
},
}));
@@ -63,6 +73,8 @@ beforeEach(() => {
jest.clearAllMocks();
mockUploadGaps = [];
mockDocumentGaps = {};
+ mockPipelineMissing = false;
+ mockAutoConfirmWarning = true;
mockUpload.mockResolvedValue(uploadOkResponse([makeDoc()]));
});
@@ -218,3 +230,97 @@ it('auto-parses every document on the no-gap path without a warning modal', asyn
run: 1,
});
});
+
+// When the dataset's configured pipeline is gone, parse-on-creation would
+// silently parse nothing, so the hook confirms first and drops the auto-parse
+// on "Continue upload".
+it('warns and uploads without parsing when the dataset pipeline is missing', async () => {
+ mockPipelineMissing = true;
+
+ const { result } = renderHook(() => useHandleUploadDocument('canvas-1'));
+ await act(async () => {
+ await result.current.onDocumentUploadOk({
+ fileList: [new File(['x'], 'a.pdf')],
+ parseOnCreation: true,
+ });
+ });
+
+ expect(mockWarning).toHaveBeenCalledTimes(1);
+ expect(mockWarning).toHaveBeenCalledWith(
+ expect.objectContaining({
+ title: 'knowledgeDetails.uploadPipelineDeletedTitle',
+ content: 'knowledgeDetails.uploadPipelineDeletedContent',
+ }),
+ );
+ await waitFor(() => expect(mockUpload).toHaveBeenCalledTimes(1));
+ await act(async () => {
+ await Promise.resolve();
+ });
+ expect(mockRun).not.toHaveBeenCalled();
+});
+
+it('uploads without a warning when parse-on-creation is off even if the pipeline is missing', async () => {
+ mockPipelineMissing = true;
+
+ const { result } = renderHook(() => useHandleUploadDocument('canvas-1'));
+ await act(async () => {
+ await result.current.onDocumentUploadOk({
+ fileList: [new File(['x'], 'a.pdf')],
+ parseOnCreation: false,
+ });
+ });
+
+ expect(mockWarning).not.toHaveBeenCalled();
+ await waitFor(() => expect(mockUpload).toHaveBeenCalledTimes(1));
+});
+
+it('chains the gap warning after the pipeline warning, then uploads without parsing', async () => {
+ mockPipelineMissing = true;
+ mockUploadGaps = [
+ { reason: 'unsupportedType', name: 'deck.pptx', fileType: 'PowerPoint' },
+ ];
+ mockUpload.mockResolvedValue(
+ uploadOkResponse([makeDoc({ id: 'doc-deck', name: 'deck.pptx' })]),
+ );
+
+ const { result } = renderHook(() => useHandleUploadDocument('canvas-1'));
+ await act(async () => {
+ await result.current.onDocumentUploadOk({
+ fileList: [new File(['x'], 'deck.pptx')],
+ parseOnCreation: true,
+ });
+ });
+
+ expect(mockWarning).toHaveBeenCalledTimes(2);
+ expect(mockWarning.mock.calls[0][0].title).toBe(
+ 'knowledgeDetails.uploadPipelineDeletedTitle',
+ );
+ expect(mockWarning.mock.calls[1][0].title).toBe(
+ 'knowledgeDetails.uploadUnsupportedTypesTitle',
+ );
+ await waitFor(() => expect(mockUpload).toHaveBeenCalledTimes(1));
+ await act(async () => {
+ await Promise.resolve();
+ });
+ expect(mockRun).not.toHaveBeenCalled();
+});
+
+it('does not upload when the pipeline warning is cancelled', async () => {
+ mockPipelineMissing = true;
+ mockAutoConfirmWarning = false;
+
+ const { result } = renderHook(() => useHandleUploadDocument('canvas-1'));
+ await act(async () => {
+ await result.current.onDocumentUploadOk({
+ fileList: [new File(['x'], 'a.pdf')],
+ parseOnCreation: true,
+ });
+ });
+
+ expect(mockWarning).toHaveBeenCalledTimes(1);
+ await act(async () => {
+ await Promise.resolve();
+ });
+ expect(mockUpload).not.toHaveBeenCalled();
+ expect(mockRun).not.toHaveBeenCalled();
+});
diff --git a/web/src/pages/dataset/dataset/use-upload-document.ts b/web/src/pages/dataset/dataset/use-upload-document.ts
index 0d6f6663e5..1f47c0c985 100644
--- a/web/src/pages/dataset/dataset/use-upload-document.ts
+++ b/web/src/pages/dataset/dataset/use-upload-document.ts
@@ -10,10 +10,11 @@ import { getUnSupportedFilesCount } from '@/utils/document-util';
import { useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { buildUploadGapModalContent } from './parser-gap-content';
+import { useDatasetPipelineMissing } from './use-dataset-pipeline-missing';
import { useParserGapValidation } from './use-parser-gap-validation';
import { hasUnsupportedTypeGap } from './utils';
-export const useHandleUploadDocument = () => {
+export const useHandleUploadDocument = (pipelineId?: string) => {
const { t } = useTranslation();
const {
visible: documentUploadVisible,
@@ -23,6 +24,7 @@ export const useHandleUploadDocument = () => {
const { uploadDocument, loading } = useUploadDocument();
const { runDocumentByIds } = useRunDocument();
const { findParseGaps, findDocumentParseGaps } = useParserGapValidation();
+ const pipelineMissing = useDatasetPipelineMissing(pipelineId);
const proceedUpload = useCallback(
async ({
@@ -97,14 +99,9 @@ export const useHandleUploadDocument = () => {
],
);
- const onDocumentUploadOk = useCallback(
+ const validateGapsAndUpload = useCallback(
async (values: UploadFormSchemaType) => {
- const { fileList } = values;
- if (fileList.length === 0) {
- return;
- }
-
- const names = fileList.map((file) =>
+ const names = values.fileList.map((file) =>
file instanceof File ? file.name : file.file.name,
);
const gaps = findParseGaps(names);
@@ -136,6 +133,35 @@ export const useHandleUploadDocument = () => {
[findParseGaps, proceedUpload, t],
);
+ const onDocumentUploadOk = useCallback(
+ async (values: UploadFormSchemaType) => {
+ if (values.fileList.length === 0) {
+ return;
+ }
+
+ // The configured pipeline can no longer parse, so parse-on-creation
+ // would silently do nothing. Confirm first; on "Continue upload" the
+ // parsing is dropped. The gap check still runs because the backend
+ // reseeds parser configs at upload regardless.
+ if (values.parseOnCreation && pipelineMissing) {
+ Modal.warning({
+ title: t('knowledgeDetails.uploadPipelineDeletedTitle'),
+ content: t('knowledgeDetails.uploadPipelineDeletedContent'),
+ okText: t('knowledgeDetails.continueUpload'),
+ cancelText: t('common.cancel'),
+ closable: false,
+ onOk: () => {
+ validateGapsAndUpload({ ...values, parseOnCreation: false });
+ },
+ });
+ return;
+ }
+
+ return validateGapsAndUpload(values);
+ },
+ [pipelineMissing, validateGapsAndUpload, t],
+ );
+
return {
documentUploadLoading: loading,
onDocumentUploadOk,