{"record":{"id":"738715dadd20e7f1","repo":"microsoft/semantic-kernel","slug":"the-provided-response-modalities-executionsettin","errorCode":null,"errorMessage":"The provided response modalities '{executionSettings.Modalities?.GetType()}' is not supported.","messagePattern":"The provided response modalities '(.+?)' is not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.AzureOpenAI/Core/AzureClientCore.ChatCompletion.cs","lineNumber":214,"sourceCode":"                }\n\n                throw new NotSupportedException($\"The provided response modalities '{modalityString}' is not supported.\");\n            }\n\n            if (responseModalitiesElement.ValueKind == JsonValueKind.Array)\n            {\n                try\n                {\n                    var modalitiesEnumeration = JsonSerializer.Deserialize<IEnumerable<string>>(responseModalitiesElement.GetRawText())!;\n                    return ParseResponseModalitiesEnumerable(modalitiesEnumeration);\n                }\n                catch (JsonException ex)\n                {\n                    throw new NotSupportedException(\"The provided response modalities JSON array may only contain strings.\", ex);\n                }\n            }\n\n            throw new NotSupportedException($\"The provided response modalities '{executionSettings.Modalities?.GetType()}' is not supported.\");\n        }\n\n        return ChatResponseModalities.Default;\n    }\n\n    /// <summary>\n    /// Gets the audio options from the execution settings.\n    /// </summary>\n    /// <param name=\"executionSettings\">The execution settings.</param>\n    /// <returns>The audio options as a <see cref=\"ChatAudioOptions\"/> object.</returns>\n    private static ChatAudioOptions GetAudioOptions(OpenAIPromptExecutionSettings executionSettings)\n    {\n        if (executionSettings.Audio is ChatAudioOptions audioOptions)\n        {\n            return audioOptions;\n        }\n\n        if (executionSettings.Audio is JsonElement audioOptionsElement)","sourceCodeStart":196,"sourceCodeEnd":232,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.AzureOpenAI/Core/AzureClientCore.ChatCompletion.cs#L196-L232","documentation":"Thrown inside GetResponseModalities when executionSettings.Modalities is a JsonElement that is neither a String ValueKind nor an Array ValueKind (e.g. Number, Object, Boolean, Null falls through earlier), so the code reports the actual runtime type of executionSettings.Modalities as unsupported. This is the catch-all for an unrecognized modality JSON shape.","triggerScenarios":"executionSettings.Modalities is a JsonElement whose ValueKind is Object or Number or True/False — e.g. {\"modalities\": {\"text\": true}} or {\"modalities\": 1}. None of the string/array branches match, so the type is reported as unsupported.","commonSituations":"Config schema drift sending a JSON object or number where an enum string/array was expected. Programmatic settings assembly assigning a numeric/object JSON value to Modalities.","solutions":["Provide Modalities as a ChatResponseModalities flags value, a valid enum-name string, an IEnumerable<string>, or a JSON string/array token — never a JSON object/number.","Correct the config so 'modalities' is a string or array of strings.","Validate the JSON token kind of modalities before binding."],"exampleFix":"// before (config)\n{ \"modalities\": { \"text\": true } }\n// throws: The provided response modalities 'System.Text.Json.JsonElement' is not supported.\n\n// after\n{ \"modalities\": \"Text\" }","handlingStrategy":"validation","validationCode":"static bool IsValidModalitiesJson(JsonElement el)\n    => el.ValueKind is JsonValueKind.String or JsonValueKind.Array;\n\n// before binding\nif (settings.Modalities is JsonElement je && !IsValidModalitiesJson(je))\n    throw new ArgumentException(\"'modalities' JSON must be a string or an array of strings.\");","typeGuard":"bool IsAcceptableModalitiesJson(JsonElement el)\n    => el.ValueKind is JsonValueKind.String or JsonValueKind.Array;","tryCatchPattern":"try { /* kernel call */ }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"response modalities\") && ex.Message.Contains(\"is not supported\"))\n{ throw new ConfigurationException(\"Unsupported modalities JSON shape; use a string or array of enum names.\", ex); }","preventionTips":["Never send a JSON object/number for 'modalities'.","Constrain 'modalities' to a string or array of strings.","Validate the JSON token kind of modalities at config load time."],"tags":["azure-openai","execution-settings","modalities","json","configuration","csharp"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}