{"record":{"id":"a88d5b2d7d357589","repo":"mastra-ai/mastra","slug":"workflow-schema-validation-failed","errorCode":"WORKFLOW_SCHEMA_VALIDATION_FAILED","errorMessage":"Invalid ${type}: \\n${validatedInputData.issues.map(e => `- ${e.path?.join('.')}: ${e.message}`).join('\\n')}","messagePattern":"Invalid (.+?): \\\\n(.+?): (.+?)`\\)\\.join\\('\\\\n'\\)\\}","errorType":"validation","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/workflow.ts","lineNumber":3460,"sourceCode":"      const workflowsStore = await this.mastra?.getStorage()?.getStore('workflows');\n      await workflowsStore?.updateWorkflowState({\n        workflowName: this.workflowId,\n        runId: this.runId,\n        opts: {\n          status: 'canceled',\n        },\n      });\n    } catch {\n      // Storage errors should not prevent cancellation from succeeding\n      // The abort signal and in-memory status are already updated\n    }\n  }\n\n  async #validateSchema<TInput>(schema: StandardSchemaWithJSON<TInput>, data: TInput, type: string) {\n    const validatedInputData = await schema['~standard'].validate(data);\n\n    if (validatedInputData.issues) {\n      throw new MastraError({\n        category: ErrorCategory.USER,\n        domain: ErrorDomain.MASTRA_WORKFLOW,\n        id: 'WORKFLOW_SCHEMA_VALIDATION_FAILED',\n        text:\n          `Invalid ${type}: \\n` + validatedInputData.issues.map(e => `- ${e.path?.join('.')}: ${e.message}`).join('\\n'),\n        details: { type },\n      });\n    }\n\n    return validatedInputData.value;\n  }\n\n  protected async _validateInput(inputData?: TInput) {\n    if (!this.validateInputs || !this.inputSchema) {\n      return inputData;\n    }\n\n    return this.#validateSchema(this.inputSchema, inputData, 'input data');","sourceCodeStart":3442,"sourceCodeEnd":3478,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/workflow.ts#L3442-L3478","documentation":"`#validateSchema` runs the workflow's input/output schemas through the Standard Schema interface before use. If validation returns issues, Mastra throws this USER error listing each failing path and message prefixed by which side (e.g. 'input'/'output') failed.","triggerScenarios":"Calling `run.start({ inputData })` (or observing a step whose schema validates output) with data that doesn't match the workflow/step Zod/Standard schema — missing required fields, wrong types, failed refinements.","commonSituations":"InputData typed loosely (any) drifting from the schema; API/CLI payloads missing required keys; schema tightened in a release while callers weren't updated; enum/refinement constraints violated.","solutions":["Read the issue list in the message (`- path: message`) and fix the inputData fields accordingly.","Validate inputs client-side with the same schema (`schema.safeParse(inputData)`) before starting the run.","If the caller is correct and the schema changed unintentionally, revert/adjust the schema.","Use `z.input<typeof workflow.inputSchema>` to type your inputData so TypeScript catches drift."],"exampleFix":"// before\nawait run.start({ inputData: { query } as any });\n// after\nconst parsed = workflow.inputSchema.parse({ query });\nawait run.start({ inputData: parsed });","handlingStrategy":"validation","validationCode":"const parsed = workflow.inputSchema.safeParse(inputData);\nif (!parsed.success) {\n  throw new Error(parsed.error.issues.map(i => `${i.path.join('.')}: ${i.message}`).join('\\n'));\n}\nawait run.start({ inputData: parsed.data });","typeGuard":"function isValidInput<S extends z.ZodTypeAny>(schema: S, data: unknown): data is z.infer<S> {\n  return schema.safeParse(data).success;\n}","tryCatchPattern":"try {\n  await run.start({ inputData });\n} catch (e) {\n  if (e instanceof MastraError && e.id === 'WORKFLOW_SCHEMA_VALIDATION_FAILED') {\n    console.error('fix inputs per issues:', e.message);\n  } else throw e;\n}","preventionTips":["Pre-parse inputData with the workflow's own schema before starting runs.","Type inputData using z.infer of the schema to catch drift at compile time.","Keep API payloads and schema in lockstep; bump schemas carefully."],"tags":["workflow","schema","validation","zod"],"backgroundTag":"schema-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}