{"record":{"id":"7647c68639cd9cfa","repo":"elsa-workflows/elsa-core","slug":"the-binding-to-activity-type-activitytype-could-not-be","errorCode":null,"errorMessage":"The binding to activity type '{activityType}' could not be deserialized: {exception.Message}","messagePattern":"The binding to activity type '(.+?)' could not be deserialized: (.+?)","errorType":"exception","errorClass":"BpmnBindingException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Bpmn.Interchange/Binding/BpmnActivityBindingFormat.cs","lineNumber":224,"sourceCode":"            var name = AttributeOf(input, InputNameAttributeName)\n                       ?? throw new BpmnBindingException($\"An <{NamespacePrefix}:{InputElementName}> element of the '{activityType}' binding declares no '{InputNameAttributeName}'.\");\n\n            if (!seenInputNameSet.Add(name))\n                throw new BpmnBindingException($\"The '{activityType}' binding declares the input '{name}' more than once. Each <{NamespacePrefix}:{InputElementName}> must name a distinct input.\");\n\n            seenInputNames.Add(name);\n            activityJson[name] = Parse(input.Value, name, activityType);\n        }\n\n        IActivity activity;\n\n        try\n        {\n            activity = activitySerializer.Deserialize(activityJson.ToJsonString());\n        }\n        catch (Exception exception) when (exception is JsonException or NotSupportedException)\n        {\n            throw new BpmnBindingException($\"The binding to activity type '{activityType}' could not be deserialized: {exception.Message}\");\n        }\n\n        // Elsa's activity serializer answers an unregistered type with a NotFoundActivity rather than throwing, and\n        // that placeholder only fails once it executes — by which time the workflow has already started and the\n        // process is mid-flight. Refusing at bind time turns \"this .bpmn needs a module you have not installed\" into a\n        // sentence naming the type, at the point where someone can still do something about it.\n        if (activity is NotFoundActivity)\n            throw new BpmnBindingException($\"The binding names activity type '{activityType}', which is not registered in this application. Install or enable the module providing it before importing this document.\");\n\n        // Elsa's own JSON deserialization ignores a member the target type does not declare, so a mistyped or\n        // stale input name would otherwise import silently as an activity missing that configuration, with no\n        // diagnostic anywhere. IActivityDescriber.GetInputProperties is the same enumeration Write reads from and\n        // ActivityDescriptor.Inputs is built from, so a name is accepted here exactly when Write could have produced\n        // it.\n        if (seenInputNames.Count > 0)\n        {\n            var declaredInputNames = activityDescriber.GetInputProperties(activity.GetType())\n                .Select(property => JsonNamingPolicy.CamelCase.ConvertName(property.Name))","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Bpmn.Interchange/Binding/BpmnActivityBindingFormat.cs#L206-L242","documentation":"The binding's assembled input JSON could not be deserialized into the target Elsa activity. Elsa's activity serializer threw a JsonException or NotSupportedException, and the binder rethrows it as a BpmnBindingException naming the activity type.","triggerScenarios":"BpmnActivityBindingFormat.Read calls activitySerializer.Deserialize(activityJson) and the serializer throws JsonException or NotSupportedException (e.g. a JSON value whose shape doesn't match the activity property type, or an unsupported type).","commonSituations":"A binding input value has the right JSON syntax but the wrong shape (string where object expected, number where enum string expected); input JSON is valid XML text but not the shape the activity expects; a module version changed the property type.","solutions":["Read the inner message (appended to this error) to find which JSON member failed, then correct that input's JSON value in the binding to match the activity property's type.","Check the activity type's declared input properties and ensure each JSON value matches (objects for complex types, proper enum strings, etc.).","If a module upgrade changed a property's type, update the binding inputs to the new shape."],"exampleFix":"// before\n<elsa:input name=\"Recipients\">\"a@b.c\"</elsa:input>  // activity expects an array\n// after\n<elsa:input name=\"Recipients\">[\"a@b.c\"]</elsa:input>","handlingStrategy":"validation","validationCode":"foreach (var raw in inputElements)\n{\n    var text = raw.Value?.Trim();\n    if (!string.IsNullOrEmpty(text))\n        JsonNode.Parse(text); // throws early with position details\n}","typeGuard":"static bool IsValidJson(string? s)\n{\n    if (string.IsNullOrWhiteSpace(s)) return true;\n    try { JsonNode.Parse(s); return true; } catch (JsonException) { return false; }\n}","tryCatchPattern":"try { await importer.ImportAsync(bpmn); }\ncatch (BpmnBindingException ex) when (ex.Message.Contains(\"could not be deserialized\"))\n{\n    logger.LogError(ex, \"Binding JSON does not match the activity type shape.\");\n}","preventionTips":["Check the activity type's declared input property types before authoring bindings","Re-validate bindings after upgrading the module that owns the activity type","Keep JSON values well-formed and shape-correct (arrays, objects, enum strings)"],"tags":["bpmn","json","deserialization"],"backgroundTag":"json-unmarshal-failed","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"}