{"record":{"id":"bdab7149303adb6c","repo":"OrchardCMS/OrchardCore","slug":"unsupported-json-token-value-valuekind-was-found","errorCode":null,"errorMessage":"Unsupported JSON token '{value.ValueKind}' was found.","messagePattern":"Unsupported JSON token '(.+?)' was found\\.","errorType":"exception","errorClass":"FormatException","httpStatus":null,"severity":"error","filePath":"src/OrchardCore/OrchardCore.Abstractions/Shell/Configuration/Internal/JsonConfigurationParser.cs","lineNumber":166,"sourceCode":"            case JsonValueKind.Null:\n\n                // Skipping null values is useful to override array items,\n                // it allows to keep non null items at the right position.\n                if (visitArray && value.ValueKind == JsonValueKind.Null)\n                {\n                    break;\n                }\n\n                var key = _paths.Peek();\n                if (_data.ContainsKey(key))\n                {\n                    throw new FormatException($\"A duplicate key '{key}' was found.\");\n                }\n                _data[key] = value.ToString();\n                break;\n\n            default:\n                throw new FormatException($\"Unsupported JSON token '{value.ValueKind}' was found.\");\n        }\n    }\n\n    private void EnterContext(string context) =>\n        _paths.Push(_paths.Count > 0 ?\n            _paths.Peek() + ConfigurationPath.KeyDelimiter + context :\n            context);\n\n    private void ExitContext() => _paths.Pop();\n}\n","sourceCodeStart":148,"sourceCodeEnd":177,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore/OrchardCore.Abstractions/Shell/Configuration/Internal/JsonConfigurationParser.cs#L148-L177","documentation":"VisitValue handles Object, Array, Number, String, True, False and Null JSON value kinds; any other ValueKind reaching the default branch throws FormatException 'Unsupported JSON token ... was found.'. In practice this is a defensive invariant for JsonValueKind values not covered (e.g. Undefined from a default-constructed element).","triggerScenarios":"Extremely rare with normal System.Text.Json parsing; occurs if a default(JsonElement) or otherwise uninitialized element (ValueKind Undefined/Uninitialized) is passed into the visitor, typically through reflection, custom subclassing, or a bug in calling code constructing elements manually.","commonSituations":"Custom code paths or tests that hand-construct JsonElement values; a framework/version change introducing a new ValueKind not yet handled by this parser; debugging tools feeding synthetic elements.","solutions":["Inspect the ValueKind reported in the message and ensure only well-formed JsonDocument/JsonElement values are traversed","Upgrade or check OrchardCore/System.Text.Json version alignment if a new JsonValueKind appeared","Avoid constructing JsonElement manually; always parse via JsonDocument.Parse","Capture the full exception with a stack trace to identify which property produced the unsupported token"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Ensure elements come from a parsed document\nusing var doc = JsonDocument.Parse(document, JOptions.Document); // ValueKinds are then always one of the supported kinds","typeGuard":null,"tryCatchPattern":"try { JsonConfigurationParser.Parse(document); }\ncatch (FormatException ex) when (ex.Message.StartsWith(\"Unsupported JSON token\"))\n{ log.LogError(ex, \"Uninitialized/unsupported JsonElement encountered\"); }","preventionTips":["Never pass default(JsonElement) or manually constructed elements","Always traverse elements obtained from JsonDocument.Parse","Keep System.Text.Json and OrchardCore versions in sync","Include stack traces when reporting to locate the offending property"],"tags":["json","configuration","invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}