elsa-workflows/elsa-core · error · JsonException
Expected an object of string metadata values.
Error message
Expected an object of string metadata values.
What it means
OrdinalIgnoreCaseDictionaryConverter.Read deserializes the secret Metadata dictionary. If the JSON token is neither null nor a start-object, the converter throws this JsonException because metadata must be a JSON object mapping property names to string values. It indicates the stored/serialized Metadata field has an incompatible shape.
Solutions
- Make metadata a JSON object of string values: "metadata": { "env": "prod" }.
- If there is no metadata, set the field to null or {}.
- Migrate old documents to the current Secret schema.
- Validate external JSON's metadata shape before deserialization.
Example fix
// before
{ "metadata": "env=prod;team=platform" }
// after
{ "metadata": { "env": "prod", "team": "platform" } } Defensive patterns
Strategy: validation
Validate before calling
using var doc = JsonDocument.Parse(json);
if (doc.RootElement.TryGetProperty("metadata", out var m) && m.ValueKind is not (JsonValueKind.Object or JsonValueKind.Null))
throw new JsonException("'metadata' must be an object of string values."); Type guard
static bool IsValidMetadataJson(JsonElement el) => el.ValueKind is JsonValueKind.Object or JsonValueKind.Null;
Try / catch
try { var secret = JsonSerializer.Deserialize<Secret>(json, options); }
catch (JsonException ex) when (ex.Message.Contains("metadata")) { /* repair metadata field or reject payload */ } Prevention
- Always serialize metadata as a string-to-string JSON object.
- Convert structured metadata to strings (or JSON-encoded values) at the boundary.
- Share the repository's serializer options when writing documents manually.
When it happens
Trigger: Deserializing a Secret where the metadata field is an array, string, or number instead of an object — e.g. "metadata": ["a","b"] or "metadata": "env=prod".
Common situations: Hand-edited stored documents; data written by an older schema or external tool; clients sending metadata as a flattened string.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Expected an array of strings.
- Expected a metadata property name.
- Cannot deserialize to .
- Failed to deserialize
- The binding to activity type
AI-assisted analysis of elsa-workflows/elsa-core@fe9217bdfa (2026-09-13).
Data as JSON: /api/errors/15cc9c33f8520209.
Report an issue: GitHub.
Appendix: source
Thrown at src/modules/Elsa.Secrets/Models/OrdinalIgnoreCaseDictionaryConverter.cs:14
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Elsa.Secrets.Models;
public class OrdinalIgnoreCaseDictionaryConverter : JsonConverter<IDictionary<string, string>>
{
public override IDictionary<string, string> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
if (reader.TokenType == JsonTokenType.Null)
return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
if (reader.TokenType != JsonTokenType.StartObject)
throw new JsonException("Expected an object of string metadata values.");
var values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
while (reader.Read())
{
if (reader.TokenType == JsonTokenType.EndObject)
return values;
if (reader.TokenType != JsonTokenType.PropertyName)
throw new JsonException("Expected a metadata property name.");
var key = reader.GetString()!;
if (!reader.Read())
throw new JsonException("Unexpected end of JSON while reading secret metadata.");
if (reader.TokenType == JsonTokenType.Null)
continue;
if (reader.TokenType != JsonTokenType.String)View on GitHub (pinned to fe9217bdfa)