{"record":{"id":"074e62b99c17b456","repo":"microsoft/semantic-kernel","slug":"response-failed","errorCode":null,"errorMessage":"Response failed","messagePattern":"Response failed","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockChatCompletionClient.cs","lineNumber":106,"sourceCode":"                activity.SetError(ex);\n                if (response != null)\n                {\n                    activityStatus = BedrockClientUtilities.ConvertHttpStatusCodeToActivityStatusCode(response.HttpStatusCode);\n                    activity.SetStatus(activityStatus);\n                    activity.SetInputTokensUsage(response?.Usage?.InputTokens ?? default);\n                    activity.SetOutputTokensUsage(response?.Usage?.OutputTokens ?? default);\n                }\n                else\n                {\n                    // If response is null, set a default status or leave it unset\n                    activity.SetStatus(ActivityStatusCode.Error); // or ActivityStatusCode.Unset\n                }\n            }\n            throw;\n        }\n        if ((response == null) || response.Output == null || response.Output.Message == null)\n        {\n            throw new InvalidOperationException(\"Response failed\");\n        }\n        IReadOnlyList<ChatMessageContent> chatMessages = this.ConvertToMessageContent(response).ToList();\n        activityStatus = BedrockClientUtilities.ConvertHttpStatusCodeToActivityStatusCode(response.HttpStatusCode);\n        activity?.SetStatus(activityStatus);\n        activity?.SetCompletionResponse(chatMessages, response.Usage.InputTokens, response.Usage.OutputTokens);\n        return chatMessages;\n    }\n\n    /// <summary>\n    /// Converts the ConverseResponse object as outputted by the Bedrock Runtime API call to a ChatMessageContent for the Semantic Kernel.\n    /// </summary>\n    /// <param name=\"response\"> ConverseResponse object outputted by Bedrock. </param>\n    /// <returns>List of ChatMessageContent objects</returns>\n    private ChatMessageContent[] ConvertToMessageContent(ConverseResponse response)\n    {\n        if (response.Output.Message == null)\n        {\n            return [];","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockChatCompletionClient.cs#L88-L124","documentation":"Thrown by BedrockChatCompletionClient.GenerateChatMessageAsync after a ConverseAsync call returned without throwing, but the response was null or had no Output/Message. It is an InvalidOperationException because the call technically completed but produced no usable content. This indicates the runtime returned an empty/malformed ConverseResponse rather than surfacing an HTTP error.","triggerScenarios":"Calling chat completion against a Bedrock model whose ConverseResponse came back with null Output or null Output.Message, e.g. a model that returned only guardrail/intervention metadata, a throttled but non-exception 200 with empty body, or a response shaped by a content-filter that dropped the message. Also seen with incompatible model ids that the Converse API accepts but returns no assistant message for.","commonSituations":"Content filtering / guardrails configured on the Bedrock model that empty the output. Hitting a non-GenAI or non-Converse-supported model id through the chat path. Transient Bedrock runtime quirk returning a null Output. Region or inference-profile mismatch producing empty content.","solutions":["Retry the identical request once (transient empty responses do occur); wrap the chat call in try/catch for InvalidOperationException.","Inspect the model's guardrail/content-filter settings and disable or relax filters that are stripping the message.","Confirm the modelId is Converse-API-compatible (most chat/text models are; some embedding-only or legacy ids are not).","Enable SK logging to capture the underlying response.HttpStatusCode captured on the activity before the throw."],"exampleFix":"// before\nvar reply = await chat.GetChatMessageContentAsync(history);\n\n// after\ntry\n{\n    var reply = await chat.GetChatMessageContentAsync(history);\n}\ncatch (InvalidOperationException ex) when (ex.Message == \"Response failed\")\n{\n    _logger.LogWarning(\"Bedrock returned an empty ConverseResponse for {ModelId}; retrying\", modelId);\n    reply = await chat.GetChatMessageContentAsync(history);\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"async Task<T> WithBedrockRetry<T>(Func<Task<T>> fn, int attempts = 2)\n{\n    for (int i = 0; ; i++)\n    {\n        try { return await fn(); }\n        catch (InvalidOperationException ex) when (ex.Message == \"Response failed\" && i < attempts - 1)\n        { _logger.LogWarning(\"Empty Bedrock chat response, retrying\"); }\n    }\n}","preventionTips":["Log response.HttpStatusCode via SK diagnostics to spot guardrail/throttle causes.","Keep a retry policy for chat completion; empty ConverseResponse can be transient.","Avoid content-filter / guardrail configs that fully suppress the assistant message."],"tags":["bedrock","chat-completion","runtime","transient","csharp"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}