microsoft/semantic-kernel · error · ArgumentException
Response is null
Error message
Response is null
What it means
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.
Source
Thrown at dotnet/src/Connectors/Connectors.Amazon/Bedrock/Core/Clients/BedrockTextEmbeddingGenerationClient.cs:103
try
{
var requestBody = splitVectorService!.GetInvokeModelRequestBody(this._modelId, text);
using var requestBodyStream = new MemoryStream(JsonSerializer.SerializeToUtf8Bytes(requestBody));
invokeRequest.Body = requestBodyStream;
response = await this._bedrockRuntime.InvokeModelAsync(invokeRequest, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
this._logger.LogError(ex, "Can't invoke with '{ModelId}'. Reason: {Error}", this._modelId, ex.Message);
throw;
}
if ((response == null) || (response.Body == null))
{
throw new ArgumentException("Response is null");
}
return splitVectorService.GetInvokeResponseBody(response);
}
private async Task<IList<ReadOnlyMemory<float>>> GenerateBatchEmbeddingsAsync(
IList<string> texts,
CancellationToken cancellationToken = default
)
{
var batchVectorService = this._ioVectorGenerationService as IBedrockCommonBatchTextEmbeddingGenerationService;
var invokeRequest = new InvokeModelRequest
{
ModelId = this._modelId,
Accept = "application/json",
ContentType = "application/json",
};
View on GitHub (pinned to c028a0c7dc)
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.
Example fix
// before
var vec = await embeddings.GenerateEmbeddingsAsync(new[] { "text" });
// after
try
{
var vec = await embeddings.GenerateEmbeddingsAsync(new[] { "text" });
}
catch (ArgumentException ex) when (ex.Message == "Response is null")
{
throw new InvalidOperationException($"Bedrock returned an empty body for embedding model '{modelId}'.", ex);
} Defensive patterns
Strategy: try-catch
Try / catch
try { await embeddings.GenerateEmbeddingsAsync(texts, ct); }
catch (ArgumentException ex) when (ex.Message == "Response is null")
{ throw new InvalidOperationException($"Bedrock returned an empty body for embedding model '{modelId}'. Verify model access in region.", ex); } Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Response failed
- Unsupported service type
- Response is null
- An error occurred while initializing the {nameof(IEmbeddingG
- An error occurred while initializing the {nameof(BedrockText
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/582458dbd4f87f83.
Report an issue: GitHub.