infiniflow/ragflow · warning · Error
flow.formatTypeError
Error message
flow.formatTypeError
What it means
Thrown by objectValidate in the agent global-variable sheet (use-object-fields.tsx) when the value entered for an object-typed variable fails key validation. validateKeys(value, []) returns a non-empty error list, meaning the value is not a parseable object with valid keys. This is a react-hook-form field validator: the error message is the i18n key 'flow.formatTypeError' shown next to the input.
Source
Thrown at web/src/pages/agent/gobal-variable-sheet/hooks/use-object-fields.tsx:102
onChange={field.onChange}
height="400px"
options={{
mode: 'code',
navigationBar: false,
mainMenuBar: true,
history: true,
onValidate: (json) => {
return validateKeys(json);
},
}}
/>
);
}, []);
const objectValidate = useCallback((value: any) => {
try {
if (validateKeys(value, [])?.length > 0) {
throw new Error(t('flow.formatTypeError'));
}
if (!z.object({}).safeParse(value).success) {
throw new Error(t('flow.formatTypeError'));
}
if (value && typeof value === 'string' && !JSON.parse(value)) {
throw new Error(t('flow.formatTypeError'));
}
return true;
} catch (e) {
console.log('object-render-error', e, value);
throw new Error(t('flow.formatTypeError'));
}
}, []);
const arrayObjectValidate = useCallback((value: any) => {
try {
if (validateKeys(value, [])?.length > 0) {
throw new Error(t('flow.formatTypeError'));View on GitHub (pinned to 554fb1133a)
Solutions
- Enter a syntactically valid JSON object, e.g. {"key": "value"}, in the variable field
- If the value was pre-filled from saved state, clear the field and re-enter it — old saved values may have a stale shape
- Check the console for the 'object-render-error' log which prints the offending value and the underlying parse error
- If an empty object should be allowed, wrap the check: skip validation when value is undefined or empty string
Example fix
// before
if (validateKeys(value, [])?.length > 0) {
throw new Error(t('flow.formatTypeError'));
}
// after
const isEmpty = value === undefined || value === null || value === '';
if (!isEmpty && validateKeys(value, [])?.length > 0) {
throw new Error(t('flow.formatTypeError'));
} Defensive patterns
Strategy: validation
Validate before calling
const isPlainObject = (v: unknown): v is Record<string, unknown> =>
typeof v === 'object' && v !== null && !Array.isArray(v);
function tryParseObjectJson(v: unknown): Record<string, unknown> | null {
const parsed = typeof v === 'string' ? JSON.parse(v) as unknown : v;
return isPlainObject(parsed) ? parsed : null;
} Type guard
function isJsonObjectString(v: unknown): v is string {
if (typeof v !== 'string' || v.trim() === '') return false;
try { return isPlainObject(JSON.parse(v)); } catch { return false; }
} Try / catch
try {
objectValidate(value);
} catch {
// react-hook-form field error; show inline, no rethrow
return { formatType: true }; // map to field error key instead of throwing Prevention
- Parse JSON editor output before it reaches the form value
- Allow empty input explicitly if empty objects are valid for your flow
- Use the console 'object-render-error' log to see the offending value when triaging
When it happens
Trigger: User types an invalid JSON object (missing braces, trailing commas, single quotes) into an object-type global variable field; or the stored value is an array/string/null instead of an object; validateKeys returns error strings whose length > 0.
Common situations: Copy-pasting JSON with trailing commas or smart quotes from a doc; pre-existing variable value saved by an older RAGFlow version in a different shape; empty input treated as invalid because validateKeys does not accept undefined.
Related errors
- Querit time_range must use dN, wN, mN, yN, or YYYY-MM-DDtoYY
- Querit {name} must be an array of strings.
- Unsupported auth_type: {auth_type}
- 101
- 'str' object has no attribute 'get'
AI-assisted analysis of infiniflow/ragflow@554fb1133a (2026-08-15).
Data as JSON: /api/errors/bd944eb13e2c4879.
Report an issue: GitHub.