{"record":{"id":"ad0deb694b030a12","repo":"elsa-workflows/elsa-core","slug":"expected-a-metadata-property-name","errorCode":null,"errorMessage":"Expected a metadata property name.","messagePattern":"Expected a metadata property name\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Secrets/Models/OrdinalIgnoreCaseDictionaryConverter.cs","lineNumber":23,"sourceCode":"\npublic class OrdinalIgnoreCaseDictionaryConverter : JsonConverter<IDictionary<string, string>>\n{\n    public override IDictionary<string, string> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n    {\n        if (reader.TokenType == JsonTokenType.Null)\n            return new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);\n\n        if (reader.TokenType != JsonTokenType.StartObject)\n            throw new JsonException(\"Expected an object of string metadata values.\");\n\n        var values = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);\n        while (reader.Read())\n        {\n            if (reader.TokenType == JsonTokenType.EndObject)\n                return values;\n\n            if (reader.TokenType != JsonTokenType.PropertyName)\n                throw new JsonException(\"Expected a metadata property name.\");\n\n            var key = reader.GetString()!;\n            if (!reader.Read())\n                throw new JsonException(\"Unexpected end of JSON while reading secret metadata.\");\n\n            if (reader.TokenType == JsonTokenType.Null)\n                continue;\n\n            if (reader.TokenType != JsonTokenType.String)\n                throw new JsonException(\"Expected a string metadata value.\");\n\n            var value = reader.GetString();\n            if (value != null)\n                values[key] = value;\n        }\n\n        throw new JsonException(\"Unexpected end of JSON while reading secret metadata.\");\n    }","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Secrets/Models/OrdinalIgnoreCaseDictionaryConverter.cs#L5-L41","documentation":"While iterating the metadata object, OrdinalIgnoreCaseDictionaryConverter.Read expects each token to be a property name; any other token triggers this JsonException. It indicates a malformed metadata object rather than a wrong overall shape.","triggerScenarios":"Deserializing a metadata object whose contents are malformed — e.g. non-property tokens inside the object because of corrupted JSON like { \"env\" \"prod\" } (missing colon) or a value token sequence produced by a buggy writer.","commonSituations":"Corrupted stored documents from partial writes; JSON produced by hand-rolled serialization that skips property names; manual edits that dropped a key.","solutions":["Repair the metadata object so every value is preceded by a property name.","Re-save the secret through the repository API rather than editing stored JSON.","Restore the document from a backup if it cannot be repaired.","Use a standard serializer (System.Text.Json) to generate metadata JSON, never string concatenation."],"exampleFix":"// before (malformed)\n{ \"metadata\": { \"env\" \"prod\" } }\n\n// after\n{ \"metadata\": { \"env\": \"prod\" } }","handlingStrategy":"validation","validationCode":"try { using var doc = JsonDocument.Parse(json); var m = doc.RootElement.GetProperty(\"metadata\"); if (m.ValueKind == JsonValueKind.Object) { foreach (var p in m.EnumerateObject()) _ = p.Name; } } catch (JsonException) { throw new InvalidOperationException(\"Metadata JSON is malformed.\"); }","typeGuard":null,"tryCatchPattern":"try { var secret = JsonSerializer.Deserialize<Secret>(json, options); }\ncatch (JsonException ex) when (ex.Message.Contains(\"property name\")) { /* repair or reject the document */ }","preventionTips":["Generate metadata JSON only with a proper serializer.","Validate stored JSON after any manual migration.","Avoid hand-editing secret documents in the database."],"tags":["json","deserialization","metadata","malformed"],"backgroundTag":"json-parse-error","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"}