{"record":{"id":"6edf7fa92cc24153","repo":"elsa-workflows/elsa-core","slug":"the-serialization-type-alias-is-missing","errorCode":null,"errorMessage":"The serialization type alias is missing.","messagePattern":"The serialization type alias is missing\\.","errorType":"validation","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Common/Serialization/SerializationTypeResolver.cs","lineNumber":60,"sourceCode":"        [typeof(IDictionary<,>)] = typeof(Dictionary<,>),\n        [typeof(IReadOnlyDictionary<,>)] = typeof(Dictionary<,>)\n    };\n\n    private static readonly IDictionary<Type, Type> CollectionInterfaceMappings = new Dictionary<Type, Type>\n    {\n        [typeof(IEnumerable)] = typeof(List<object>),\n        [typeof(ICollection)] = typeof(List<object>),\n        [typeof(IList)] = typeof(List<object>),\n        [typeof(IDictionary)] = typeof(Dictionary<string, object>)\n    };\n\n    /// <summary>\n    /// Resolves the specified serialization type alias.\n    /// </summary>\n    public static Type ResolveType(ISerializationTypeRegistry serializationTypeRegistry, string? typeAlias)\n    {\n        if (string.IsNullOrWhiteSpace(typeAlias))\n            throw new JsonException(\"The serialization type alias is missing.\");\n\n        if (TryResolveType(serializationTypeRegistry, typeAlias, out var type))\n            return type;\n\n        throw new JsonException(\n            $\"Unknown serialization type alias '{typeAlias}'. Only registered aliases and supported compound aliases can be deserialized.\");\n    }\n\n    /// <summary>\n    /// Attempts to resolve the specified serialization type alias.\n    /// </summary>\n    public static bool TryResolveType(ISerializationTypeRegistry serializationTypeRegistry, string typeAlias, out Type type)\n    {\n        IReadOnlyList<Type>? registeredTypes = null;\n        return TryResolveType(serializationTypeRegistry, typeAlias, ref registeredTypes, out type);\n    }\n\n    private static bool TryResolveType(ISerializationTypeRegistry serializationTypeRegistry, string typeAlias, ref IReadOnlyList<Type>? registeredTypes, out Type type)","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Common/Serialization/SerializationTypeResolver.cs#L42-L78","documentation":"SerializationTypeResolver.ResolveType resolves a serialization type alias through ISerializationTypeRegistry. An empty/whitespace/null alias throws this JsonException (a distinct message from the unknown-alias error that follows registry lookup).","triggerScenarios":"Deserializing payload where the type-discriminator property (e.g. $type/type alias field) is absent, null, or an empty string, and the resolver is invoked with that value.","commonSituations":"Hand-written or trimmed JSON missing the type field; serializers configured with an alias-writing setting disabled; migrations dropping the discriminator property; clients posting polymorphic payloads without the type metadata.","solutions":["Ensure serialized payloads include the type-alias property with a non-empty registered alias.","Enable/restore Elsa's type-alias serialization settings so the discriminator is written.","Check the input JSON for a missing/empty \"type\"/alias field at the failing path.","If the alias is optional in your scenario, use TryResolveType which tolerates missing aliases instead."],"exampleFix":"// before\n{\"activity\": {\"id\": \"a1\"}}\n// after\n{\"activity\": {\"type\": \"HttpEndpoint\", \"id\": \"a1\"}}","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(typeAlias))\n    throw new JsonException(\"Payload is missing the required type-alias discriminator.\");","typeGuard":"bool HasTypeAlias(JsonElement e, string prop = \"type\") => e.ValueKind == JsonValueKind.Object && e.TryGetProperty(prop, out var p) && p.ValueKind == JsonValueKind.String && !string.IsNullOrWhiteSpace(p.GetString());","tryCatchPattern":"try { type = SerializationTypeResolver.ResolveType(registry, alias); }\ncatch (JsonException ex) when (ex.Message.Contains(\"alias\")) { logger.LogError(ex, \"Bad or missing type alias in payload\"); }","preventionTips":["Always serialize polymorphic payloads with Elsa's type-alias settings enabled","Validate inbound JSON contains the discriminator before deserialization","Register all custom aliases in ISerializationTypeRegistry at startup"],"tags":["json","serialization","type-alias"],"backgroundTag":"missing-required-argument","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}