{"record":{"id":"c7258ca1e17204a9","repo":"mastra-ai/mastra","slug":"unknown-step-entry-type-json-stringify-exhaust","errorCode":null,"errorMessage":"Unknown step entry type: ${JSON.stringify(_exhaustive)}","messagePattern":"Unknown step entry type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/workflows/dynamic/serialize.ts","lineNumber":103,"sourceCode":"    }\n    case 'loop': {\n      const predicate = entry.predicate;\n      if (!predicate || typeof predicate !== 'object') {\n        throw new Error(\n          `Loop step \"${getSingleStepEntryId(entry.step)}\" cannot be stored: closure predicates do not round-trip. Use the declarative form ({ predicate: {...} }).`,\n        );\n      }\n      return {\n        type: 'loop',\n        step: serializeSingleEntry(entry.step),\n        serializedCondition: entry.serializedCondition,\n        loopType: entry.loopType,\n        predicate,\n      };\n    }\n    default: {\n      const _exhaustive: never = entry;\n      throw new Error(`Unknown step entry type: ${JSON.stringify(_exhaustive)}`);\n    }\n  }\n}\n\nfunction serializeSingleEntry(entry: SingleStepEntry): SerializedSingleStepEntry {\n  if (entry.type === 'agent') {\n    const options = pickSerializableStepOptions(entry.options, entry.id, 'agent');\n    const outputSchema = extractStructuredOutputJsonSchema(entry.options, entry.id);\n    return {\n      type: 'agent',\n      id: entry.id,\n      agentId: entry.agentId,\n      description: entry.agent?.description,\n      ...(outputSchema ? { outputSchema } : {}),\n      ...(options ? { options } : {}),\n    };\n  }\n  if (entry.type === 'tool') {","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/workflows/dynamic/serialize.ts#L85-L121","documentation":"This is the exhaustive-switch default in `serializeEntry`: TypeScript's `never` check catches a `StepFlowEntry` variant the serializer doesn't recognize — usually a newly added entry type the switch wasn't updated for, or a corrupted/foreign object injected into the `stepFlow`. The thrown message embeds the JSON of the unexpected entry for diagnosis.","triggerScenarios":"Calling `toStorableGraph` with a `stepFlow` array containing an entry whose `type` is not one of step/agent/tool/mapping/sleep/sleepUntil/parallel/foreach/conditional/loop — e.g. hand-assembled entries, entries from a newer core version, or data loaded from storage with an unknown type.","commonSituations":"Upgrading @mastra/core and feeding old persisted graphs forward; custom tooling that constructs StepFlowEntry objects manually; type assertions (`as any`) hiding a malformed entry from the compiler.","solutions":["Log/inspect the embedded JSON (`entry.type`) to identify the unknown variant.","Update @mastra/core to a version whose serializer supports the entry type, or downgrade the producer of the graph.","If the entry is hand-built, construct it via the library's supported entry factories instead.","If you maintain core, extend the switch with a case for the new entry type so exhaustiveness holds."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"const KNOWN_TYPES = new Set(['step','agent','tool','mapping','sleep','sleepUntil','parallel','foreach','conditional','loop']);\nfor (const e of stepFlow) {\n  if (!e || !KNOWN_TYPES.has(e.type)) throw new Error(`Unknown step entry type: ${JSON.stringify(e)}`);\n}","typeGuard":"const isKnownEntryType = (e: unknown): e is StepFlowEntry =>\n  !!e && typeof e === 'object' && KNOWN_TYPES.has((e as any).type);","tryCatchPattern":"try {\n  storable = toStorableGraph(stepFlow);\n} catch (e) {\n  if (/Unknown step entry type/.test(e.message)) {\n    const detail = JSON.parse(e.message.slice(e.message.indexOf(':') + 1));\n    // inspect detail.type; fix producer or upgrade @mastra/core\n  } else throw e;\n}","preventionTips":["Construct entries only via library factories; avoid `as any` casts into StepFlowEntry.","Keep producer and @mastra/core versions aligned for persisted graphs.","Validate persisted graphs against the current schema before reload."],"tags":["workflows","serialization","exhaustiveness","schema-mismatch"],"backgroundTag":"unknown-enum-value","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}