Skip to content

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

Fix: Click to create an agent; if the name already exists, an error will be displayed in the name input field. (#19324)

balibabu7d8f7f6bb372
diff --git a/web/src/locales/en.ts b/web/src/locales/en.ts
index a54990cca6..378743e08b 100644
--- a/web/src/locales/en.ts
+++ b/web/src/locales/en.ts
@@ -3166,6 +3166,7 @@ Best for: Documents with flowing, contextually connected content — such as boo
contentTip: 'content: Email content (Optional)',
jsonUploadTypeErrorMessage: 'Please upload json file',
jsonUploadContentErrorMessage: 'json file error',
+ nameExists: 'Name already exists',
iteration: 'Iteration',
iterationDescription: `A looping component that iterates over an input array and executes a defined logic for each item.`,
delimiterTip: `
diff --git a/web/src/locales/zh.ts b/web/src/locales/zh.ts
index 94f4e853a0..81deac02fd 100644
--- a/web/src/locales/zh.ts
+++ b/web/src/locales/zh.ts
@@ -2782,6 +2782,7 @@ NER:使用 spaCy NER 和基于规则的关键词提取来抽取 Entities 和 R
contentTip: 'content: 邮件内容(可选)',
jsonUploadTypeErrorMessage: '请上传 json 文件',
jsonUploadContentErrorMessage: 'json 文件错误',
+ nameExists: '名称已存在',
iteration: '迭代',
iterationDescription: `该组件负责迭代生成新的内容,对列表对象执行多次步骤直至输出所有结果。`,
delimiterTip: `该分隔符用于将输入文本分割成几个文本片段,每个文本片段的回显将作为每次迭代的输入项。`,
diff --git a/web/src/pages/agents/compilation-template-card.tsx b/web/src/pages/agents/compilation-template-card.tsx
index f93ad98f5e..ca6497fa09 100644
--- a/web/src/pages/agents/compilation-template-card.tsx
+++ b/web/src/pages/agents/compilation-template-card.tsx
@@ -46,7 +46,7 @@ export function CompilationTemplateCard({
<section className="flex items-center justify-between gap-2">
<TruncatedText
as="h3"
- className="flex-1 min-w-0 truncate"
+ className="flex-1 min-w-0 truncate text-base font-bold leading-snug"
tooltip={data.name}
>
{data.name}
diff --git a/web/src/pages/agents/upload-agent-dialog/upload-agent-form.tsx b/web/src/pages/agents/upload-agent-dialog/upload-agent-form.tsx
index ebbbe0c765..29a41b7574 100644
--- a/web/src/pages/agents/upload-agent-dialog/upload-agent-form.tsx
+++ b/web/src/pages/agents/upload-agent-dialog/upload-agent-form.tsx
@@ -2,6 +2,7 @@
import { zodResolver } from '@hookform/resolvers/zod';
import { useForm } from 'react-hook-form';
+import { useTranslation } from 'react-i18next';
import { z } from 'zod';
import { FileUploader } from '@/components/file-uploader';
@@ -24,7 +25,15 @@ export const FormSchema = z.object({
});
export type FormSchemaType = z.infer<typeof FormSchema>;
+
+// Both backends report a duplicate title with the generic data-error code
+// (Python RetCode.DATA_ERROR, Go 102), so the message is matched as well.
+function isDuplicateNameError(ret?: { code?: number; message?: string }) {
+ return ret?.code === 102 && ret.message?.includes('already exists');
+}
+
export function UploadAgentForm({ hideModal, onOk }: IModalProps<any>) {
+ const { t } = useTranslation();
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: { name: '' },
@@ -32,8 +41,10 @@ export function UploadAgentForm({ hideModal, onOk }: IModalProps<any>) {
async function onSubmit(data: FormSchemaType) {
const ret = await onOk?.(data);
- if (ret) {
+ if (ret?.code === 0) {
hideModal?.();
+ } else if (isDuplicateNameError(ret)) {
+ form.setError('name', { type: 'server', message: t('flow.nameExists') });
}
}
diff --git a/web/src/pages/agents/use-import-json.ts b/web/src/pages/agents/use-import-json.ts
index c009d6cc88..55b38d3297 100644
--- a/web/src/pages/agents/use-import-json.ts
+++ b/web/src/pages/agents/use-import-json.ts
@@ -37,14 +37,13 @@ export const useHandleImportJsonFile = () => {
if (graphOrDslStr && !isEmpty(rawParsed)) {
const isAgent = inferIsAgentFromImport(rawParsed);
const dsl = bridge.importDsl(rawParsed, isAgent);
- setAgent({
+ return await setAgent({
title: name,
dsl,
canvas_category: isAgent
? AgentCategory.AgentCanvas
: AgentCategory.DataflowCanvas,
});
- hideFileUploadModal();
} else {
message.error(errorMessage);
}
@@ -53,7 +52,7 @@ export const useHandleImportJsonFile = () => {
}
}
},
- [hideFileUploadModal, setAgent, t, toast],
+ [setAgent, t, toast],
);
return {