{"record":{"id":"09ead0b86a27ff1a","repo":"mastra-ai/mastra","slug":"cannot-create-workflow-definition-input-id-i","errorCode":null,"errorMessage":"Cannot create workflow definition \"${input.id}\": inputSchema, outputSchema, and graph are required.","messagePattern":"Cannot create workflow definition \"(.+?)\": inputSchema, outputSchema, and graph are required\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/storage/domains/workflow-definitions/inmemory.ts","lineNumber":56,"sourceCode":"        ...('status' in input && input.status !== undefined && { status: input.status }),\n        ...('authorId' in input && input.authorId !== undefined && { authorId: input.authorId }),\n        updatedAt: now,\n      };\n      this.db.workflowDefinitions.set(input.id, merged);\n      return this.deepCopy(merged);\n    }\n\n    // Creation requires the full schema set + graph. Check values, not key\n    // presence — `{ graph: undefined }` must not slip through.\n    if (\n      !('inputSchema' in input) ||\n      input.inputSchema === undefined ||\n      !('outputSchema' in input) ||\n      input.outputSchema === undefined ||\n      !('graph' in input) ||\n      input.graph === undefined\n    ) {\n      throw new Error(\n        `Cannot create workflow definition \"${input.id}\": inputSchema, outputSchema, and graph are required.`,\n      );\n    }\n\n    const def: WorkflowDefinition = {\n      id: input.id,\n      description: input.description,\n      metadata: input.metadata,\n      inputSchema: input.inputSchema,\n      outputSchema: input.outputSchema,\n      stateSchema: input.stateSchema,\n      requestContextSchema: input.requestContextSchema,\n      graph: input.graph,\n      status: 'active',\n      source: 'storage',\n      authorId: 'authorId' in input ? input.authorId : undefined,\n      createdAt: now,\n      updatedAt: now,","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/storage/domains/workflow-definitions/inmemory.ts#L38-L74","documentation":"`upsert` in the workflow-definitions storage requires a definition record to carry non-undefined `inputSchema`, `outputSchema`, and `graph` fields. If any is missing or explicitly undefined, it refuses to persist the definition, since these three fields define the workflow contract and executable structure.","triggerScenarios":"Calling `upsert({ id, name, description })` (or via `updated`) with a partial input lacking `inputSchema`/`outputSchema`/`graph`, or spreading an object where those keys are present but set to undefined.","commonSituations":"Persisting a minimal/partial workflow record to 'reserve' an ID, migrating older records whose schema predates the required fields, or deserialization dropping optional-looking fields before upsert.","solutions":["Provide all three fields: derive `inputSchema`/`outputSchema` from the workflow (e.g. zod `.jsonSchema()` or zod-to-json-schema) and `graph` from the serialized workflow graph.","If updating an existing definition, load it first and merge the existing schemas/graph instead of upserting a partial record.","Validate the input payload shape before calling upsert.","Fix serialization so `undefined` fields are not stripped or turned into explicit undefined values."],"exampleFix":"// before\nawait wfStorage.upsert({ id: 'wf-1', name: 'My flow' });\n// after\nawait wfStorage.upsert({\n  id: 'wf-1',\n  name: 'My flow',\n  inputSchema: z.object({}).jsonSchema(),\n  outputSchema: z.object({}).jsonSchema(),\n  graph: serializedGraph,\n});","handlingStrategy":"validation","validationCode":"function assertWorkflowDefinitionInput(input: { id: string; inputSchema?: unknown; outputSchema?: unknown; graph?: unknown }) {\n  const missing: string[] = [];\n  if (input.inputSchema === undefined) missing.push('inputSchema');\n  if (input.outputSchema === undefined) missing.push('outputSchema');\n  if (input.graph === undefined) missing.push('graph');\n  if (missing.length) throw new Error(`Workflow definition \"${input.id}\" missing: ${missing.join(', ')}`);\n}","typeGuard":"function isCompleteWorkflowDefinition(\n  input: Partial<{ inputSchema: unknown; outputSchema: unknown; graph: unknown }>,\n): input is { inputSchema: unknown; outputSchema: unknown; graph: unknown } {\n  return 'inputSchema' in input && input.inputSchema !== undefined\n    && 'outputSchema' in input && input.outputSchema !== undefined\n    && 'graph' in input && input.graph !== undefined;\n}","tryCatchPattern":"try {\n  await wfStorage.upsert(input);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('inputSchema, outputSchema, and graph are required')) {\n    const existing = await wfStorage.getDefinition(input.id); // merge missing fields\n    await wfStorage.upsert({ ...existing, ...input });\n  } else throw err;\n}","preventionTips":["Always build definitions from a complete workflow object (schemas via zodToJsonSchema, graph from the workflow).","For updates, load the existing definition and spread it under the patch.","Validate payloads with a schema before persistence."],"tags":["schema-validation","workflow","missing-field"],"backgroundTag":"missing-required-field","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}