{"record":{"id":"a55a9c2ace495046","repo":"mastra-ai/mastra","slug":"your-schema-is-async-which-is-not-supported-plea-a55a9c","errorCode":null,"errorMessage":"Your schema is async, which is not supported. Please use a sync schema.","messagePattern":"Your schema is async, which is not supported\\. Please use a sync schema\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/workflow.ts","lineNumber":3495,"sourceCode":"\n    return this.#validateSchema(this.inputSchema, inputData, 'input data');\n  }\n\n  protected async _validateInitialState(initialState?: TState) {\n    if (!this.validateInputs || !this.stateSchema) {\n      return initialState;\n    }\n\n    return this.#validateSchema(this.stateSchema, initialState, 'initial data');\n  }\n\n  protected async _validateRequestContext(requestContext?: RequestContext) {\n    if (this.validateInputs && this.requestContextSchema) {\n      const contextValues = getRequestContextInputValues(requestContext);\n      const validation = this.requestContextSchema['~standard'].validate(contextValues);\n\n      if (validation instanceof Promise) {\n        throw new Error('Your schema is async, which is not supported. Please use a sync schema.');\n      }\n\n      if (!('value' in validation)) {\n        const errors = validation.issues;\n        throw new Error(\n          `Request context validation failed for workflow '${this.workflowId}': \\n` +\n            errors\n              .map(e => {\n                const pathStr = e.path?.map(p => (typeof p === 'object' ? p.key : p)).join('.');\n                return `- ${pathStr}: ${e.message}`;\n              })\n              .join('\\n'),\n        );\n      }\n    }\n  }\n\n  protected async _validateResumeData<TResume>(resumeData: TResume, suspendedStep?: StepWithComponent) {","sourceCodeStart":3477,"sourceCodeEnd":3513,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/workflow.ts#L3477-L3513","documentation":"When `validateInputs` is enabled and a `requestContextSchema` is set, `_validateRequestContext` validates request-context values synchronously. Because Mastra must validate synchronously here, an async schema (one whose `~standard.validate` returns a Promise) is rejected outright with this error.","triggerScenarios":"Passing an async schema (e.g. a Zod schema with async `.refine()`/`.transform()`, or a custom Standard Schema with async validate) as `requestContextSchema` on a workflow with `validateInputs: true`, then calling createRun/start/execution methods.","commonSituations":"Adding an async refinement (DB lookup, remote check) to the request-context schema; using async transforms from shared schemas; enabling validateInputs on an existing workflow with an async schema.","solutions":["Make requestContextSchema fully synchronous: remove async refine/transform and async superRefine.","Perform async lookups outside the schema — validate in your own code and pass already-resolved values via requestContext.","If the async check is required, drop `validateInputs: true` or the requestContextSchema and validate manually before starting the run.","Use sync-only schema features (plain shapes, sync refine) for request contexts."],"exampleFix":"// before\nrequestContextSchema: z.object({ tenantId: z.string().refine(async id => exists(id)) }),\n// after\nrequestContextSchema: z.object({ tenantId: z.string() }),\n// do the async existence check before createRun and pass validated values","handlingStrategy":"validation","validationCode":"function assertSyncSchema(schema: { '~standard': { validate: (v: unknown) => unknown } }) {\n  const probe = schema['~standard'].validate({});\n  if (probe instanceof Promise) throw new Error('requestContextSchema must be synchronous');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await workflow.createRun({ requestContext });\n} catch (e) {\n  if (e instanceof Error && e.message.includes('Your schema is async')) {\n    // rebuild requestContextSchema without async refinements\n  } else throw e;\n}","preventionTips":["Keep requestContextSchema free of async refine/transform.","Resolve async lookups before createRun and pass final values.","Note: z.string().refine(async ...) or .transform(async ...) makes the whole schema async."],"tags":["workflow","request-context","schema","async"],"backgroundTag":"async-schema-unsupported","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}