{"record":{"id":"77f6cd7d2b1731f4","repo":"microsoft/semantic-kernel","slug":"response-is-null-77f6cd","errorCode":null,"errorMessage":"Response is null","messagePattern":"Response is null","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockTextGenerationClient.cs","lineNumber":110,"sourceCode":"            if (activity is not null)\n            {\n                activity.SetError(ex);\n                if (response != null)\n                {\n                    activityStatus = BedrockClientUtilities.ConvertHttpStatusCodeToActivityStatusCode(response.HttpStatusCode);\n                    activity.SetStatus(activityStatus);\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.Body == null))\n        {\n            throw new ArgumentException(\"Response is null\");\n        }\n        activityStatus = BedrockClientUtilities.ConvertHttpStatusCodeToActivityStatusCode(response.HttpStatusCode);\n        activity?.SetStatus(activityStatus);\n        IReadOnlyList<TextContent> textResponse = this._ioTextService.GetInvokeResponseBody(response);\n        activity?.SetCompletionResponse(textResponse);\n        return textResponse;\n    }\n\n    internal async IAsyncEnumerable<StreamingTextContent> StreamTextAsync(\n        string prompt,\n        PromptExecutionSettings? executionSettings = null,\n        Kernel? kernel = null,\n        [EnumeratorCancellation] CancellationToken cancellationToken = default)\n    {\n        Verify.NotNullOrWhiteSpace(prompt);\n        var requestBody = this._ioTextService.GetInvokeModelRequestBody(this._modelId, prompt, executionSettings);\n        var invokeRequest = new InvokeModelWithResponseStreamRequest\n        {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockTextGenerationClient.cs#L92-L128","documentation":"Thrown by BedrockTextGenerationClient when InvokeModelAsync returned a response that is null or whose Body is null (non-throwing but empty). It is an ArgumentException guarding the GetInvokeResponseBody parse step in the text-generation (InvokeModel) path.","triggerScenarios":"Text generation (non-streaming) call where the Bedrock InvokeModel response had no Body. Occurs with a model id the runtime accepts but returns an empty body for, content-policy interventions, or transient empty responses.","commonSituations":"Using a non-text model id in the text-generation path. Model not enabled in region. Content filter emptying the response. Transient transport anomaly.","solutions":["Confirm modelId is a Bedrock text-generation model and is enabled in the region.","Retry once on this ArgumentException; empty bodies can be transient.","Wrap the text-generation call in try/catch (ArgumentException) and log modelId + region.","Check the model's content-filter/guardrail configuration."],"exampleFix":"// before\nvar text = await textGen.GetTextContentAsync(\"prompt\", settings);\n\n// after\ntry\n{\n    var text = await textGen.GetTextContentAsync(\"prompt\", settings);\n}\ncatch (ArgumentException ex) when (ex.Message == \"Response is null\")\n{\n    throw new InvalidOperationException($\"Bedrock returned an empty body for text model '{modelId}'.\", ex);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { var text = await textGen.GetTextContentAsync(prompt, settings, ct); }\ncatch (ArgumentException ex) when (ex.Message == \"Response is null\")\n{ throw new InvalidOperationException($\"Bedrock returned an empty body for text model '{modelId}'.\", ex); }","preventionTips":["Use a Bedrock text-generation modelId enabled in the region.","Retry once on transient empty bodies.","Log modelId and HTTP status via SK diagnostics."],"tags":["bedrock","text-generation","runtime","csharp"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}