{"record":{"id":"16743bb41c55f496","repo":"mastra-ai/mastra","slug":"invalid-data-item","errorCode":"INVALID_DATA_ITEM","errorMessage":"Invalid data item at index ${i}: must have 'input', 'inputs', or 'turns' property","messagePattern":"Invalid data item at index (.+?): must have 'input', 'inputs', or 'turns' property","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/evals/run/index.ts","lineNumber":690,"sourceCode":"): void {\n  const hasGates = !!gates && gates.length > 0;\n  if (data.length === 0) {\n    throw new MastraError({\n      domain: 'SCORER',\n      id: 'RUN_EXPERIMENT_FAILED_NO_DATA_PROVIDED',\n      category: 'USER',\n      text: 'Failed to run experiment: Data array is empty',\n    });\n  }\n\n  // Tracks whether any data item carries per-turn gates/scorers, which (like\n  // top-level scorers/gates) satisfies the \"at least one scorer or gate\" rule.\n  let hasAnyTurnAssertions = false;\n\n  for (let i = 0; i < data.length; i++) {\n    const item = data[i];\n    if (!item || typeof item !== 'object' || (!('input' in item) && !('inputs' in item) && !('turns' in item))) {\n      throw new MastraError({\n        domain: 'SCORER',\n        id: 'INVALID_DATA_ITEM',\n        category: 'USER',\n        text: `Invalid data item at index ${i}: must have 'input', 'inputs', or 'turns' property`,\n      });\n    }\n    if ('inputs' in item) {\n      if (!Array.isArray(item.inputs) || item.inputs.length === 0) {\n        throw new MastraError({\n          domain: 'SCORER',\n          id: 'INVALID_DATA_ITEM',\n          category: 'USER',\n          text: `Invalid data item at index ${i}: 'inputs' must be a non-empty array`,\n        });\n      }\n      if (isWorkflow(target)) {\n        throw new MastraError({\n          domain: 'SCORER',","sourceCodeStart":672,"sourceCodeEnd":708,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/evals/run/index.ts#L672-L708","documentation":"Each item in an eval dataset must be an object containing at least one of `input`, `inputs`, or `turns`. `validateEvalsInputs` iterates the data array and throws a MastraError (id INVALID_DATA_ITEM, category USER) at the first index that is null/non-object or lacks all three keys. This is a dataset shape contract enforced before running the experiment.","triggerScenarios":"Calling runEvals with items like `null`, strings/numbers, `{}` (missing keys), or objects using the wrong key such as `{ prompt: ... }` or `{ messages: ... }` — thrown at the first offending index `i`.","commonSituations":"Hand-written datasets with inconsistent key names; migrating from an older eval format (`inputs` -> `input` or the new `turns` for multi-turn); mapping over an array that produced `undefined` entries; JSON parse producing scalars for some lines of a JSONL file.","solutions":["Give every data item an `input` key (or `inputs` for multi-input, `turns` for conversations)","Normalize the dataset before calling runEvals: map raw records into `{ input: ... }` shape","Validate/parse the dataset with a schema (zod) before running to catch bad indices early","Check for holes/undefined entries created by `map`/`filter` on sparse arrays"],"exampleFix":"// before\nconst data = [\n  { prompt: 'What is 2+2?' }, // wrong key -> INVALID_DATA_ITEM\n];\n// after\nconst data = [\n  { input: 'What is 2+2?' },\n];","handlingStrategy":"validation","validationCode":"function isValidDataItem(item) {\n  return !!item && typeof item === 'object'\n    && ('input' in item || 'inputs' in item || 'turns' in item);\n}\ndata.forEach((item, i) => { if (!isValidDataItem(item)) throw new Error(`Bad eval item at index ${i}`); });","typeGuard":"function isEvalDataItem(item: unknown): item is { input?: unknown; inputs?: unknown; turns?: unknown } {\n  return typeof item === 'object' && item !== null\n    && ('input' in item || 'inputs' in item || 'turns' in item);\n}\nconst valid: EvalItem[] = data.filter(isEvalDataItem);","tryCatchPattern":"try {\n  await mastra.runEvals({ data, scorers, target });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'INVALID_DATA_ITEM') {\n    console.error(e.message); // names the offending index — fix that record's shape\n  } else throw e;\n}","preventionTips":["Standardize dataset items on the `input` key in a shared type/zod schema","Validate the whole dataset with a schema before calling runEvals","When migrating formats, normalize records to the current shape instead of mixing keys"],"tags":["evals","dataset","validation","schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}