FlowiseAI/Flowise · error · Error
chatflowId must be a valid array
Error message
chatflowId must be a valid array
What it means
EvaluationRunner.runEvaluations parses data.chatflowId via JSON.parse and requires the result to be an array. The error is thrown when the parsed value is not an Array (e.g. a plain string, number, or object), meaning the caller did not supply a JSON-serialized array of chatflow IDs. This is a request-shape validation guard before the evaluation loop iterates over chatflowIds.
Source
Thrown at packages/components/evaluation/EvaluationRunner.ts:93
EvaluationRunner.metrics.set(id, [metric])
}
}
baseURL = ''
constructor(baseURL: string) {
this.baseURL = baseURL
}
getChatflowApiKey(chatflowId: string, apiKeys: { chatflowId: string; apiKey: string }[] = []) {
return apiKeys.find((item) => item.chatflowId === chatflowId)?.apiKey || ''
}
public async runEvaluations(data: ICommonObject) {
const chatflowIds = JSON.parse(data.chatflowId)
if (!Array.isArray(chatflowIds)) {
throw new Error('chatflowId must be a valid array')
}
if (!data.dataset || !Array.isArray(data.dataset.rows)) {
throw new Error('dataset.rows must be a valid array')
}
const returnData: ICommonObject = {}
returnData.evaluationId = data.evaluationId
returnData.runDate = new Date()
returnData.rows = []
for (let i = 0; i < data.dataset.rows.length; i++) {
returnData.rows.push({
input: data.dataset.rows[i].input,
expectedOutput: data.dataset.rows[i].output,
itemNo: data.dataset.rows[i].sequenceNo,
evaluations: [],
status: 'pending'
})View on GitHub (pinned to abe4a8601a)
Solutions
- Serialize the chatflow IDs before calling: data.chatflowId = JSON.stringify(['flow-1','flow-2']).
- If only one chatflow is evaluated, still wrap it: JSON.stringify([singleId]).
- Validate the shape on the caller side with Array.isArray(JSON.parse(...)) before invoking runEvaluations.
- Update the API/UI layer to always emit a JSON array string for the chatflowId field.
Example fix
// before data.chatflowId = selectedChatflowId // 'abc123' // after data.chatflowId = JSON.stringify([selectedChatflowId]) // '["abc123"]'
Defensive patterns
Strategy: validation
Validate before calling
function normalizeChatflowIds(raw) {
let parsed
try { parsed = typeof raw === 'string' ? JSON.parse(raw) : raw } catch { parsed = null }
if (!Array.isArray(parsed) || parsed.length === 0) {
throw new Error('chatflowId must be a JSON-serialized non-empty array, e.g. JSON.stringify(["flow-1"])')
}
return JSON.stringify(parsed)
}
// before calling runEvaluations:
data.chatflowId = normalizeChatflowIds(data.chatflowId) Type guard
function isChatflowIdArray(value) {
try {
const p = typeof value === 'string' ? JSON.parse(value) : value
return Array.isArray(p) && p.every((x) => typeof x === 'string')
} catch { return false }
} Try / catch
try {
await runner.runEvaluations(data)
} catch (e) {
if (e.message === 'chatflowId must be a valid array') {
// fix data.chatflowId to JSON.stringify([...]) and retry
} else throw e
} Prevention
- Always serialize chatflow ids with JSON.stringify at the API/UI boundary.
- Document the chatflowId field as a JSON array string in your API contract.
- Add an integration test that posts a single-id array to catch regressions.
When it happens
Trigger: Calling runEvaluations({ chatflowId: 'abc123' }) (a bare id string), or chatflowId set to a JSON object like '{"id":1}', or an already-unwrapped non-JSON value. Also triggers if chatflowId is undefined, because JSON.parse(undefined) throws SyntaxError before reaching the isArray check (different message, but related misuse).
Common situations: Frontend sending a single selected chatflow id instead of JSON.stringify([id]); API client forgetting to serialize the array; CSV/import tooling passing raw identifiers; mismatch between API docs (which expect a JSON array string) and caller implementation.
Related errors
- dataset.rows must be a valid array
- Invalid JSON in executeFlowOverrideConfig: ${parseError.mess
- Invalid input array
- Invalid Flow State
- Expected partitioning request to return an array, but got ${
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/564ab37e750266f0.
Report an issue: GitHub.