{"record":{"id":"8a7cf0332e11c258","repo":"elsa-workflows/elsa-core","slug":"expected-an-array-of-strings","errorCode":null,"errorMessage":"Expected an array of strings.","messagePattern":"Expected an array of strings\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Secrets/Models/CaseInsensitiveHashSetConverter.cs","lineNumber":14,"sourceCode":"using System.Text.Json;\nusing System.Text.Json.Serialization;\n\nnamespace Elsa.Secrets.Models;\n\npublic class CaseInsensitiveHashSetConverter : JsonConverter<HashSet<string>>\n{\n    public override HashSet<string> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)\n    {\n        if (reader.TokenType == JsonTokenType.Null)\n            return new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n\n        if (reader.TokenType != JsonTokenType.StartArray)\n            throw new JsonException(\"Expected an array of strings.\");\n\n        var values = new HashSet<string>(StringComparer.OrdinalIgnoreCase);\n        while (reader.Read())\n        {\n            if (reader.TokenType == JsonTokenType.EndArray)\n                return values;\n\n            if (reader.TokenType != JsonTokenType.String)\n                throw new JsonException(\"Expected a string tag.\");\n\n            var value = reader.GetString();\n            if (!string.IsNullOrWhiteSpace(value))\n                values.Add(value);\n        }\n\n        throw new JsonException(\"Unexpected end of JSON while reading secret tags.\");\n    }\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Secrets/Models/CaseInsensitiveHashSetConverter.cs#L1-L32","documentation":"CaseInsensitiveHashSetConverter.Read deserializes a HashSet<string> of secret tags. If the JSON token is neither null nor a start-array, the converter throws this JsonException because only a JSON array is a valid representation for tags. This indicates malformed or incompatible stored/serialized JSON for the Tags property.","triggerScenarios":"Deserializing a Secret (or payload containing Tags) where the tags field is a string, object, or number instead of a JSON array — e.g. stored data from an older schema or hand-edited JSON.","commonSituations":"Manual database edits of secret documents; data produced by a different serializer or library version; feeding user-supplied JSON into a Secret-shaped model without validation.","solutions":["Fix the JSON so tags is an array of strings, e.g. \"tags\": [\"prod\", \"api\"].","If the value should be empty, set it to null (converter returns an empty set) or an empty array [].","Migrate old-format documents to the current Secret JSON schema.","Validate external JSON against the Secret schema before deserializing."],"exampleFix":"// before\n{ \"tags\": \"prod,api\" }\n\n// after\n{ \"tags\": [\"prod\", \"api\"] }","handlingStrategy":"validation","validationCode":"using var doc = JsonDocument.Parse(json);\nif (doc.RootElement.TryGetProperty(\"tags\", out var t) && t.ValueKind is not (JsonValueKind.Array or JsonValueKind.Null))\n    throw new JsonException(\"'tags' must be an array of strings.\");","typeGuard":"static bool IsValidTagsJson(JsonElement el) => el.ValueKind is JsonValueKind.Array or JsonValueKind.Null;","tryCatchPattern":"try { return JsonSerializer.Deserialize<Secret>(json, options); }\ncatch (JsonException ex) when (ex.Message.Contains(\"array of strings\")) { /* repair tags field or reject payload */ }","preventionTips":["Always serialize tags as a JSON array of strings.","Validate secret JSON before storing or deserializing.","Use the same serializer options the repository uses when writing documents manually."],"tags":["json","deserialization","tags","validation"],"backgroundTag":"invalid-argument-format","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"}