{"record":{"id":"bbfc2430db81167a","repo":"mastra-ai/mastra","slug":"inputs-cannot-be-null-or-undefined","errorCode":null,"errorMessage":"Inputs cannot be null or undefined","messagePattern":"Inputs cannot be null or undefined","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/evals/src/scorers/code/completeness/index.ts","lineNumber":101,"sourceCode":"    type: 'agent',\n  })\n    .preprocess(async ({ run }) => {\n      const isInputInvalid =\n        !run.input ||\n        run.input.inputMessages.some((i: MastraDBMessage) => {\n          const content = getTextContentFromMastraDBMessage(i);\n          return content === null || content === undefined;\n        });\n\n      const isOutputInvalid =\n        !run.output ||\n        run.output.some((i: MastraDBMessage) => {\n          const content = getTextContentFromMastraDBMessage(i);\n          return content === null || content === undefined;\n        });\n\n      if (isInputInvalid || isOutputInvalid) {\n        throw new Error('Inputs cannot be null or undefined');\n      }\n\n      const input = run.input?.inputMessages.map(i => getTextContentFromMastraDBMessage(i)).join(', ') || '';\n      const output = run.output?.map(i => getTextContentFromMastraDBMessage(i)).join(', ') || '';\n\n      const inputToProcess = input;\n      const outputToProcess = output;\n\n      const inputDoc = nlp(inputToProcess.trim());\n      const outputDoc = nlp(outputToProcess.trim());\n\n      // Extract and log elements\n      const inputElements = extractElements(inputDoc);\n      const outputElements = extractElements(outputDoc);\n\n      return {\n        inputElements,\n        outputElements,","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/evals/src/scorers/code/completeness/index.ts#L83-L119","documentation":"The completeness scorer validates that both the input messages and output messages of the run contain non-null, non-undefined text content before measuring completeness. It checks every input and output message's extracted text content; if any message yields null or undefined content, it throws rather than producing a misleadingly low score. This is a fail-fast guard against malformed run data.","triggerScenarios":"Running completenessScorer on a run whose input or output messages contain a message where getTextContentFromMastraDBMessage returns null/undefined — e.g. a message with no content parts, only tool calls with no text, or an empty content array.","commonSituations":"Scoring runs that ended in tool-call-only turns with no final assistant text; passing hand-built run objects in tests with placeholder messages; version drift where message content shape changed and the extractor no longer finds text.","solutions":["Ensure every input and output message in the scored run contains text content (assistant messages should end with a text part)","Filter out messages with null/undefined content before calling the scorer","If runs legitimately end with tool calls, append or require a final textual assistant response before scoring","Log the offending run's messages to find which message lacks text content and fix its construction"],"exampleFix":"// before\nawait completenessScorer.run({ input: { inputMessages: messages }, output });\n\n// after\nconst hasText = (m: MastraDBMessage) => getTextContentFromMastraDBMessage(m) != null;\nconst usable = output.filter(hasText);\nif (usable.length) await completenessScorer.run({ input: { inputMessages: messages.filter(hasText) }, output: usable });","handlingStrategy":"validation","validationCode":"import { getTextContentFromMastraDBMessage } from '@mastra/core/';\nconst isValid = (msgs: MastraDBMessage[]) => msgs.every(m => getTextContentFromMastraDBMessage(m) != null);\nif (!isValid(run.input?.inputMessages ?? []) || !isValid(run.output ?? [])) {\n  throw new Error('Run contains messages without text content; fix before scoring');\n}","typeGuard":"function hasTextContent(m: MastraDBMessage): boolean {\n  return getTextContentFromMastraDBMessage(m) !== null && getTextContentFromMastraDBMessage(m) !== undefined;\n}","tryCatchPattern":"try {\n  await completenessScorer.run(run);\n} catch (err) {\n  if ((err as Error).message === 'Inputs cannot be null or undefined') {\n    console.warn('Skipping run: message without text content');\n    return null;\n  }\n  throw err;\n}","preventionTips":["Filter messages with null text content before scoring","Ensure agent runs end with a textual assistant response, not only tool calls","Use typed run fixtures from the scorer's expected schema in tests","Log the offending messages when a run fails scoring"],"tags":["evals","scorer","completeness","null-validation"],"backgroundTag":"null-or-undefined-input","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}