{"record":{"id":"61fb27ba1698818f","repo":"elsa-workflows/elsa-core","slug":"none-of-the-specified-keys-were-found-string-join-names","errorCode":null,"errorMessage":"None of the specified keys were found: {string.Join(\", \", names)}","messagePattern":"None of the specified keys were found: (.+?)","errorType":"exception","errorClass":"KeyNotFoundException","httpStatus":null,"severity":"error","filePath":"src/modules/Elsa.Workflows.Core/Extensions/JsonElementExtensions.cs","lineNumber":17,"sourceCode":"using System.Text.Json;\n\n// ReSharper disable once CheckNamespace\nnamespace Elsa.Extensions;\n\npublic static class JsonElementExtensions\n{\n    /// <summary>\n    /// Returns a child element where its name matches any of the specified names.\n    /// </summary>\n    public static JsonElement GetProperty(this JsonElement element, params string[] names)\n    {\n        foreach (var name in names)\n            if (element.TryGetProperty(name, out var value))\n                return value;\n\n        throw new KeyNotFoundException($\"None of the specified keys were found: {string.Join(\", \", names)}\");\n    }\n}","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/elsa-workflows/elsa-core/blob/fe9217bdfa0e27f0e09e45006eb6898f616e513d/src/modules/Elsa.Workflows.Core/Extensions/JsonElementExtensions.cs#L1-L19","documentation":"JsonElementExtensions.GetProperty(element, params string[] names) returns the first matching property among the candidate names and throws KeyNotFoundException when none of them exist on the JSON element. It is a convenience lookup for tolerant JSON property access in Elsa. Since JsonElement has no such multi-key lookup natively, Elsa throws rather than returning default.","triggerScenarios":"Calling element.GetProperty(\"state\", \"status\") on a JSON payload that contains neither key; parsing a webhook/API payload whose schema differs from expected (e.g. wrong casing, renamed field, empty object).","commonSituations":"Third-party API changed its response schema; deserializing with wrong casing options; accessing a property on an empty or array JsonElement; consuming a payload from a different event/version.","solutions":["Confirm the actual JSON keys at runtime (e.g. log element.ToString()) and pass the correct name","Add the alternate key names to the params list, or use element.TryGetProperty before calling","Guard with a custom helper that returns a default value instead of throwing","Validate the payload schema before parsing"],"exampleFix":"// before\nvar status = doc.RootElement.GetProperty(\"state\", \"status\");\n// after\nvar status = doc.RootElement.TryGetProperty(\"state\", out var el) ? el.GetString() : null;","handlingStrategy":"type-guard","validationCode":"bool HasAny(JsonElement el, params string[] names) => names.Any(n => el.ValueKind == JsonValueKind.Object && el.TryGetProperty(n, out _));","typeGuard":"bool TryGetString(JsonElement el, out string? value, params string[] names) { foreach (var n in names) if (el.TryGetProperty(n, out var v) && v.ValueKind == JsonValueKind.String) { value = v.GetString(); return true; } value = null; return false; }","tryCatchPattern":"try { prop = element.GetProperty(\"state\", \"status\"); } catch (KeyNotFoundException) { prop = default; }","preventionTips":["Log raw payloads when integrating with external APIs","Prefer TryGetProperty with fallbacks over multi-name throwing helpers","Pin/validate payload schemas when the producer may change"],"tags":["json","key-not-found"],"backgroundTag":"record-not-found","analyzedSha":"fe9217bdfa0e27f0e09e45006eb6898f616e513d","analyzedAt":"2026-09-13T20:32:34.702Z","contentChangedAt":"2026-09-13T20:32:34.702Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}