fix: add fallback parser list for empty parser_ids (#12632)

### What problem does this PR solve?

Fixes #12570 - The slicing method dropdown was empty when deploying
RAGFlow v0.23.1 from source code.

The issue occurred because `parser_ids` from the tenant info was empty
or undefined, causing `useSelectParserList` to return an empty array.
This PR adds a fallback to a default parser list when `parser_ids` is
empty, ensuring the dropdown always has options.

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

---
Contribution by Gittensor, see my contribution statistics at
https://gittensor.io/miners/details?githubId=94194147
This commit is contained in:
MkDev11
2026-01-15 01:05:25 -05:00
committed by GitHub
parent b40a7b2e7d
commit 97b983fd0b

View File

@ -112,6 +112,23 @@ export const useFetchTenantInfo = (
return { data, loading }; return { data, loading };
}; };
const DEFAULT_PARSERS = [
{ value: 'naive', label: 'General' },
{ value: 'qa', label: 'Q&A' },
{ value: 'resume', label: 'Resume' },
{ value: 'manual', label: 'Manual' },
{ value: 'table', label: 'Table' },
{ value: 'paper', label: 'Paper' },
{ value: 'book', label: 'Book' },
{ value: 'laws', label: 'Laws' },
{ value: 'presentation', label: 'Presentation' },
{ value: 'picture', label: 'Picture' },
{ value: 'one', label: 'One' },
{ value: 'audio', label: 'Audio' },
{ value: 'email', label: 'Email' },
{ value: 'tag', label: 'Tag' },
];
export const useSelectParserList = (): Array<{ export const useSelectParserList = (): Array<{
value: string; value: string;
label: string; label: string;
@ -120,7 +137,13 @@ export const useSelectParserList = (): Array<{
const parserList = useMemo(() => { const parserList = useMemo(() => {
const parserArray: Array<string> = tenantInfo?.parser_ids?.split(',') ?? []; const parserArray: Array<string> = tenantInfo?.parser_ids?.split(',') ?? [];
return parserArray.map((x) => { const filteredArray = parserArray.filter((x) => x.trim() !== '');
if (filteredArray.length === 0) {
return DEFAULT_PARSERS;
}
return filteredArray.map((x) => {
const arr = x.split(':'); const arr = x.split(':');
return { value: arr[0], label: arr[1] }; return { value: arr[0], label: arr[1] };
}); });