{"record":{"id":"ddea06430fa74e5f","repo":"FlowiseAI/Flowise","slug":"dataset-rows-must-be-a-valid-array","errorCode":null,"errorMessage":"dataset.rows must be a valid array","messagePattern":"dataset\\.rows must be a valid array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/evaluation/EvaluationRunner.ts","lineNumber":97,"sourceCode":"    baseURL = ''\n\n    constructor(baseURL: string) {\n        this.baseURL = baseURL\n    }\n\n    getChatflowApiKey(chatflowId: string, apiKeys: { chatflowId: string; apiKey: string }[] = []) {\n        return apiKeys.find((item) => item.chatflowId === chatflowId)?.apiKey || ''\n    }\n\n    public async runEvaluations(data: ICommonObject) {\n        const chatflowIds = JSON.parse(data.chatflowId)\n\n        if (!Array.isArray(chatflowIds)) {\n            throw new Error('chatflowId must be a valid array')\n        }\n\n        if (!data.dataset || !Array.isArray(data.dataset.rows)) {\n            throw new Error('dataset.rows must be a valid array')\n        }\n\n        const returnData: ICommonObject = {}\n        returnData.evaluationId = data.evaluationId\n        returnData.runDate = new Date()\n        returnData.rows = []\n        for (let i = 0; i < data.dataset.rows.length; i++) {\n            returnData.rows.push({\n                input: data.dataset.rows[i].input,\n                expectedOutput: data.dataset.rows[i].output,\n                itemNo: data.dataset.rows[i].sequenceNo,\n                evaluations: [],\n                status: 'pending'\n            })\n        }\n        for (let i = 0; i < chatflowIds.length; i++) {\n            const chatflowId = chatflowIds[i]\n            await this.evaluateChatflow(chatflowId, this.getChatflowApiKey(chatflowId, data.apiKeys), data, returnData)","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/evaluation/EvaluationRunner.ts#L79-L115","documentation":"EvaluationRunner.runEvaluations requires data.dataset to exist and data.dataset.rows to be an Array. It guards the subsequent loop that indexes data.dataset.rows[i].input/output/sequenceNo. Thrown when the dataset payload is missing, not an object, or its rows field is absent/non-array.","triggerScenarios":"Calling runEvaluations without a dataset field; passing dataset as null; passing dataset.rows as an object/CSV string instead of an array; uploading a dataset whose parser returned undefined; partial payload from a truncated request body.","commonSituations":"Dataset upload step skipped or failed silently; UI sending { dataset: { columns: [...] } } but omitting rows; backend deserializer mapping rows to a different key; testing with a stubbed empty payload.","solutions":["Ensure the payload includes dataset.rows as an array, e.g. data.dataset = { rows: [{ input, output, sequenceNo }, ...] }.","Verify the dataset upload/import pipeline returns an array before assigning it to data.dataset.rows.","Add a caller-side guard: if (!data?.dataset?.rows?.length) throw a clearer upstream error.","Check that the HTTP request body was not truncated/clipped by a proxy or body-size limit."],"exampleFix":"// before\ndata.dataset = { columns: ['input','output'] } // no rows\n\n// after\ndata.dataset = {\n  rows: datasetRows.map(r => ({ input: r.input, output: r.output, sequenceNo: r.sequenceNo }))\n}","handlingStrategy":"validation","validationCode":"function validateDataset(data) {\n  if (!data?.dataset || !Array.isArray(data.dataset.rows) || data.dataset.rows.length === 0) {\n    throw new Error('data.dataset.rows must be a non-empty array of { input, output, sequenceNo }')\n  }\n  return data.dataset.rows\n}\nconst rows = validateDataset(data)","typeGuard":"function isDatasetRows(value) {\n  return !!value?.dataset && Array.isArray(value.dataset.rows)\n}","tryCatchPattern":"try {\n  await runner.runEvaluations(data)\n} catch (e) {\n  if (e.message.startsWith('dataset.rows')) {\n    // rebuild data.dataset.rows from the source dataset and retry\n  } else throw e\n}","preventionTips":["Run the dataset through a parser that guarantees an array before assignment.","Unit-test the upload/import path with empty/malformed inputs.","Reject empty datasets at the UI before submission."],"tags":["validation","evaluation","dataset","api-contract"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}