elsa-workflows/elsa-core · error · BpmnBindingException

Input ' ' of the ' ' binding does not hold valid JSON

Error message

Input '{inputName}' of the '{activityType}' binding does not hold valid JSON: {exception.Message}

What it means

Thrown by the private Parse helper of BpmnActivityBindingFormat (invoked while reading binding inputs) when a declared binding input, expected to be JSON, cannot be parsed by JsonNode.Parse. It is a validation guard translating the underlying JsonException into a BpmnBindingException that names the offending input and activity type; null input is coerced to JSON null and does not fire.

Solutions

  1. Quote string values and fix the JSON syntax of the named input so JsonNode.Parse succeeds.
  2. Check the inner message for the exact position of the JSON syntax error and correct that character/structure.
  3. For non-string values, use proper JSON (numbers, true/false, arrays, objects) rather than XML-ish text.

Example fix

// before
<elsa:input name="Count">3 items</elsa:input>
// after
<elsa:input name="Count">3</elsa:input>
Defensive patterns

Strategy: type-guard

Type guard

static bool IsParsableJson(string? s)
{
    if (string.IsNullOrWhiteSpace(s)) return true;
    try { JsonNode.Parse(s); return true; } catch (JsonException) { return false; }
}

Try / catch

try { await importer.ImportAsync(bpmn); }
catch (BpmnBindingException ex) when (ex.Message.Contains("does not hold valid JSON"))
{
    logger.LogError(ex, "An <elsa:input> value is not valid JSON; quote strings and fix syntax.");
}

Prevention

When it happens

Trigger: BpmnActivityBindingFormat.Parse (called from Read) invokes JsonNode.Parse on an <elsa:input> element's value and a JsonException is thrown — e.g. unquoted text, trailing commas, or raw identifiers.

Common situations: Writing <elsa:input name="X">hello</elsa:input> instead of quoted JSON "hello"; pasting C#/XML snippets instead of JSON; empty or malformed values from manual edits.

Understand the failure class

Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.

Related errors


AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13). Data as JSON: /api/errors/7fbeb5bf0787008d. Report an issue: GitHub.

Appendix: source

Thrown at src/modules/Elsa.Bpmn.Interchange/Binding/BpmnActivityBindingFormat.cs:267

                var noun = undeclaredInputNames.Count == 1 ? "an input" : "inputs";
                var names = string.Join(", ", undeclaredInputNames.Select(name => $"'{name}'"));

                throw new BpmnBindingException($"The '{activityType}' binding declares {noun} {names}, which '{activityType}' does not have.");
            }
        }

        return activity;
    }

    private static JsonNode? Parse(string? json, string inputName, string activityType)
    {
        try
        {
            return JsonNode.Parse(json ?? "null");
        }
        catch (JsonException exception)
        {
            throw new BpmnBindingException($"Input '{inputName}' of the '{activityType}' binding does not hold valid JSON: {exception.Message}");
        }
    }

    private static BpmnForeignAttribute Attribute(string name, string value) => new(new(null, name), value);

    // An unprefixed XML attribute belongs to no namespace, which is what the reader records for these; comparing on
    // the local name alone would also match a same-named attribute some other vendor put in its own namespace.
    private static string? AttributeOf(BpmnExtensionElement element, string name) =>
        element.Attributes.FirstOrDefault(attribute => string.IsNullOrEmpty(attribute.Name.Namespace) && attribute.Name.LocalName == name)?.Value;
}

View on GitHub (pinned to fe9217bdfa)