{"record":{"id":"582458dbd4f87f83","repo":"microsoft/semantic-kernel","slug":"response-is-null","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/BedrockTextEmbeddingGenerationClient.cs","lineNumber":103,"sourceCode":"\n        try\n        {\n            var requestBody = splitVectorService!.GetInvokeModelRequestBody(this._modelId, text);\n            using var requestBodyStream = new MemoryStream(JsonSerializer.SerializeToUtf8Bytes(requestBody));\n            invokeRequest.Body = requestBodyStream;\n\n            response = await this._bedrockRuntime.InvokeModelAsync(invokeRequest, cancellationToken).ConfigureAwait(false);\n        }\n        catch (Exception ex)\n        {\n            this._logger.LogError(ex, \"Can't invoke with '{ModelId}'. Reason: {Error}\", this._modelId, ex.Message);\n\n            throw;\n        }\n\n        if ((response == null) || (response.Body == null))\n        {\n            throw new ArgumentException(\"Response is null\");\n        }\n\n        return splitVectorService.GetInvokeResponseBody(response);\n    }\n\n    private async Task<IList<ReadOnlyMemory<float>>> GenerateBatchEmbeddingsAsync(\n        IList<string> texts,\n        CancellationToken cancellationToken = default\n    )\n    {\n        var batchVectorService = this._ioVectorGenerationService as IBedrockCommonBatchTextEmbeddingGenerationService;\n        var invokeRequest = new InvokeModelRequest\n        {\n            ModelId = this._modelId,\n            Accept = \"application/json\",\n            ContentType = \"application/json\",\n        };\n","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockTextEmbeddingGenerationClient.cs#L85-L121","documentation":"Thrown by GetEmbeddingForSingleTextAsync (single-text embedding path, e.g. Titan) when InvokeModelAsync returned a response that is null or whose Body stream is null. The earlier try/catch only catches thrown exceptions, so a non-throwing but empty InvokeModelResponse reaches this ArgumentException.","triggerScenarios":"Per-text embedding call where the Bedrock InvokeModel response came back non-null on the call but with a null Body, or the call returned null without throwing (rare AWS SDK path). Happens with a model id that Bedrock accepts but returns no body for, or a transient SDK/transport anomaly that yields an empty response object.","commonSituations":"Wrong/typo modelId that is not actually an embedding model but passes validation. Network/SDK edge case. Mismatched Accept/ContentType for a given model. Pointing the embedding service at a region where the model is unavailable.","solutions":["Confirm the modelId is a real Bedrock embedding model and is enabled in the current region.","Retry once on this ArgumentException as it can be transient.","Check IAM/region/model-access (model invocation access must be granted in the Bedrock console).","Wrap GenerateEmbeddingsAsync in try/catch (ArgumentException) and log this._modelId context."],"exampleFix":"// before\nvar vec = await embeddings.GenerateEmbeddingsAsync(new[] { \"text\" });\n\n// after\ntry\n{\n    var vec = await embeddings.GenerateEmbeddingsAsync(new[] { \"text\" });\n}\ncatch (ArgumentException ex) when (ex.Message == \"Response is null\")\n{\n    throw new InvalidOperationException($\"Bedrock returned an empty body for embedding model '{modelId}'.\", ex);\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { await embeddings.GenerateEmbeddingsAsync(texts, ct); }\ncatch (ArgumentException ex) when (ex.Message == \"Response is null\")\n{ throw new InvalidOperationException($\"Bedrock returned an empty body for embedding model '{modelId}'. Verify model access in region.\", ex); }","preventionTips":["Confirm the embedding model is enabled in the Bedrock console for the region.","Retry once; empty bodies can be transient.","Wrap embedding calls with structured logging of modelId and region."],"tags":["bedrock","embeddings","runtime","csharp"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}