Skip to content

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

Fix: The `exesql` operator, when used as an agent tool, does not display mandatory field validation information in the checklist. (#21490)

balibabuc14c745674bb
diff --git a/web/src/pages/agent/components/canvas-checklist.test.tsx b/web/src/pages/agent/components/canvas-checklist.test.tsx
index 619e50013c..05557e88db 100644
--- a/web/src/pages/agent/components/canvas-checklist.test.tsx
+++ b/web/src/pages/agent/components/canvas-checklist.test.tsx
@@ -24,6 +24,12 @@ describe('CanvasChecklist', () => {
useGraphStore.setState({ nodeFocusRequest: null });
});
+ it('renders nothing when there are no issues', () => {
+ const { container } = render(<CanvasChecklist issues={[]} />);
+
+ expect(container).toBeEmptyDOMElement();
+ });
+
it('posts a node focus request with the form opened for variable issues', () => {
render(<CanvasChecklist issues={[issue]} />);
diff --git a/web/src/pages/agent/components/canvas-checklist.tsx b/web/src/pages/agent/components/canvas-checklist.tsx
index 8a4a97bed5..fb18b5f245 100644
--- a/web/src/pages/agent/components/canvas-checklist.tsx
+++ b/web/src/pages/agent/components/canvas-checklist.tsx
@@ -121,6 +121,11 @@ export function CanvasChecklist({ issues }: { issues: CanvasIssue[] }) {
[requestNodeFocus],
);
+ // No issues, no checklist — the button only exists to surface problems.
+ if (issues.length === 0) {
+ return null;
+ }
+
return (
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
@@ -141,31 +146,25 @@ export function CanvasChecklist({ issues }: { issues: CanvasIssue[] }) {
{t('flow.checklistTitle')}
</p>
</div>
- {issues.length === 0 ? (
- <div className="px-4 py-6 text-center text-sm text-text-secondary">
- {t('flow.checklistEmpty')}
- </div>
- ) : (
- <div className="max-h-80 space-y-2 overflow-y-auto p-2">
- {groups.map((group) => (
- <section key={group.key} className="rounded-lg bg-bg-card p-1.5">
- <header className="flex items-center gap-2 px-1.5 py-1 text-sm font-medium text-text-primary">
- <OperatorIcon name={group.operatorLabel as Operator} />
- <span className="truncate">{group.nodeName}</span>
- </header>
- <ul>
- {group.items.map((issue, index) => (
- <ChecklistIssueItem
- key={`${issue.messageKey}-${issue.messageParams?.variable ?? index}`}
- issue={issue}
- onLocate={handleLocate}
- />
- ))}
- </ul>
- </section>
- ))}
- </div>
- )}
+ <div className="max-h-80 space-y-2 overflow-y-auto p-2">
+ {groups.map((group) => (
+ <section key={group.key} className="rounded-lg bg-bg-card p-1.5">
+ <header className="flex items-center gap-2 px-1.5 py-1 text-sm font-medium text-text-primary">
+ <OperatorIcon name={group.operatorLabel as Operator} />
+ <span className="truncate">{group.nodeName}</span>
+ </header>
+ <ul>
+ {group.items.map((issue, index) => (
+ <ChecklistIssueItem
+ key={`${issue.messageKey}-${issue.messageParams?.variable ?? index}`}
+ issue={issue}
+ onLocate={handleLocate}
+ />
+ ))}
+ </ul>
+ </section>
+ ))}
+ </div>
</PopoverContent>
</Popover>
);
diff --git a/web/src/pages/agent/form/exesql-form/index.tsx b/web/src/pages/agent/form/exesql-form/index.tsx
index 47b4abb448..0c7a0d06f7 100644
--- a/web/src/pages/agent/form/exesql-form/index.tsx
+++ b/web/src/pages/agent/form/exesql-form/index.tsx
@@ -2,19 +2,11 @@ import NumberInput from '@/components/originui/number-input';
import { SelectWithSearch } from '@/components/originui/select-with-search';
import { RAGFlowFormItem } from '@/components/ragflow-form';
import { ButtonLoading } from '@/components/ui/button';
-import {
- Form,
- FormControl,
- FormField,
- FormItem,
- FormLabel,
- FormMessage,
-} from '@/components/ui/form';
+import { Form } from '@/components/ui/form';
import { Input } from '@/components/ui/input';
-import { useTranslate } from '@/hooks/common-hooks';
import { zodResolver } from '@hookform/resolvers/zod';
import { memo } from 'react';
-import { useForm, useFormContext } from 'react-hook-form';
+import { useForm, useFormContext, useWatch } from 'react-hook-form';
import { useTranslation } from 'react-i18next';
import { z } from 'zod';
import { initialExeSqlValues } from '../../constant';
@@ -39,121 +31,52 @@ const outputList = buildOutputList(initialExeSqlValues.outputs);
export function ExeSQLFormWidgets({ loading }: { loading: boolean }) {
const form = useFormContext();
- const { t } = useTranslate('flow');
+ const { t } = useTranslation();
+ // Password is only required for password-authenticated databases; trino
+ // connects without one (mirrors the superRefine in FormSchema).
+ const dbType = useWatch({ control: form.control, name: 'db_type' });
return (
<>
- <FormField
- control={form.control}
- name="db_type"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('dbType')}</FormLabel>
- <FormControl>
- <SelectWithSearch
- {...field}
- options={ExeSQLOptions}
- ></SelectWithSearch>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="database"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('database')}</FormLabel>
- <FormControl>
- <Input {...field}></Input>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="username"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('username')}</FormLabel>
- <FormControl>
- <Input {...field}></Input>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="host"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('host')}</FormLabel>
- <FormControl>
- <Input {...field}></Input>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
- name="port"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('port')}</FormLabel>
- <FormControl>
- <NumberInput
- {...field}
- min={MinPort}
- max={MaxPort}
- integer
- className="w-full"
- ></NumberInput>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
- <FormField
- control={form.control}
+ <RAGFlowFormItem name="db_type" label={t('flow.dbType')} required>
+ <SelectWithSearch options={ExeSQLOptions}></SelectWithSearch>
+ </RAGFlowFormItem>
+ <RAGFlowFormItem name="database" label={t('flow.database')} required>
+ <Input></Input>
+ </RAGFlowFormItem>
+ <RAGFlowFormItem name="username" label={t('flow.username')} required>
+ <Input></Input>
+ </RAGFlowFormItem>
+ <RAGFlowFormItem name="host" label={t('flow.host')} required>
+ <Input></Input>
+ </RAGFlowFormItem>
+ <RAGFlowFormItem name="port" label={t('flow.port')} required>
+ <NumberInput
+ min={MinPort}
+ max={MaxPort}
+ integer
+ className="w-full"
+ ></NumberInput>
+ </RAGFlowFormItem>
+ <RAGFlowFormItem
name="password"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('password')}</FormLabel>
- <FormControl>
- <Input {...field} type="password"></Input>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
-
- <FormField
- control={form.control}
- name="max_records"
- render={({ field }) => (
- <FormItem>
- <FormLabel>{t('maxRecords')}</FormLabel>
- <FormControl>
- <NumberInput
- {...field}
- min={MinMaxRecords}
- max={MaxMaxRecords}
- integer
- className="w-full"
- ></NumberInput>
- </FormControl>
- <FormMessage />
- </FormItem>
- )}
- />
+ label={t('flow.password')}
+ required={dbType !== 'trino'}
+ >
+ <Input type="password"></Input>
+ </RAGFlowFormItem>
+ <RAGFlowFormItem name="max_records" label={t('flow.maxRecords')} required>
+ <NumberInput
+ min={MinMaxRecords}
+ max={MaxMaxRecords}
+ integer
+ className="w-full"
+ ></NumberInput>
+ </RAGFlowFormItem>
<div className="flex justify-end">
<ButtonLoading loading={loading} type="submit">
- {t('test')}
+ {t('flow.test')}
</ButtonLoading>
</div>
</>
diff --git a/web/src/pages/agent/utils/__tests__/canvas-checklist.test.ts b/web/src/pages/agent/utils/__tests__/canvas-checklist.test.ts
index 92da74f9ec..9e979019a7 100644
--- a/web/src/pages/agent/utils/__tests__/canvas-checklist.test.ts
+++ b/web/src/pages/agent/utils/__tests__/canvas-checklist.test.ts
@@ -911,7 +911,19 @@ describe('collectCanvasIssues: required tool API key', () => {
name: 'Sofya',
params: { api_key: 'secret' },
},
- { component_name: 'ExeSQL', id: 'tool-2', params: {} },
+ {
+ component_name: 'ExeSQL',
+ id: 'tool-2',
+ params: {
+ db_type: 'mysql',
+ database: 'db',
+ username: 'root',
+ host: 'db.internal',
+ port: 3306,
+ password: 'secret',
+ max_records: 1024,
+ },
+ },
],
});
@@ -921,6 +933,63 @@ describe('collectCanvasIssues: required tool API key', () => {
issues.filter((x) => x.messageKey === 'flow.apiKeyMissing'),
).toHaveLength(0);
});
+
+ it('flags an agent-embedded ExeSQL tool with incomplete connection fields', () => {
+ const agent = makeNode('Agent:a1', 'Agent', {
+ llm_id: 'model-1',
+ tools: [
+ {
+ component_name: 'ExeSQL',
+ id: 'tool-1',
+ name: 'QueryOrders',
+ params: { db_type: 'mysql', username: 'root', port: 3306 },
+ },
+ ],
+ });
+
+ const issues = collect({
+ nodes: [agent, makeNode('Tool:t1', 'Tool')],
+ edges: [makeEdge('Agent:a1', 'Tool:t1', 'tool')],
+ });
+
+ expect(issues).toContainEqual(
+ expect.objectContaining({
+ nodeId: 'Tool:t1',
+ toolId: 'tool-1',
+ nodeName: 'Agent:a1 / QueryOrders',
+ operatorLabel: 'ExeSQL',
+ type: CanvasIssueType.MissingRequired,
+ messageKey: 'flow.nodeFormInvalid',
+ blocksRun: true,
+ }),
+ );
+ });
+
+ it('passes an agent-embedded ExeSQL tool with complete connection fields', () => {
+ const agent = makeNode('Agent:a1', 'Agent', {
+ llm_id: 'model-1',
+ tools: [
+ {
+ component_name: 'ExeSQL',
+ id: 'tool-1',
+ params: {
+ db_type: 'trino',
+ database: 'db',
+ username: 'root',
+ host: 'db.internal',
+ port: 8080,
+ max_records: 1024,
+ },
+ },
+ ],
+ });
+
+ const issues = collect({ nodes: [agent] });
+
+ expect(
+ issues.filter((x) => x.messageKey === 'flow.nodeFormInvalid'),
+ ).toHaveLength(0);
+ });
});
describe('collectCanvasIssues: agent-embedded retrieval tools', () => {
diff --git a/web/src/pages/agent/utils/canvas-checklist.ts b/web/src/pages/agent/utils/canvas-checklist.ts
index 3aee45b7b6..d408259e0b 100644
--- a/web/src/pages/agent/utils/canvas-checklist.ts
+++ b/web/src/pages/agent/utils/canvas-checklist.ts
@@ -775,6 +775,20 @@ export function collectCanvasIssues({
operatorLabel: tool.component_name ?? Operator.Tool,
};
issues.push(...collectSearchFilterIssues(tool?.params, toolTarget));
+ // Embedded ExeSQL tools omit `sql` (the agent writes it), which the
+ // schema allows; the connection fields are validated the same way as
+ // the standalone node.
+ if (
+ tool?.component_name === Operator.ExeSQL &&
+ !ExeSQLFormSchema.safeParse(tool.params).success
+ ) {
+ issues.push({
+ ...toolTarget,
+ type: CanvasIssueType.MissingRequired,
+ messageKey: 'flow.nodeFormInvalid',
+ blocksRun: true,
+ });
+ }
if (isRetrieval) {
issues.push(
...collectRetrievalBindingIssues(tool?.params, toolTarget, {