BedrockRuntime: DocumentSource S3Location fails with "source.type: Field required"
- Dominant language
- C#
- Stars
- 140
- Forks
- 891
- Avg merge
- 21h 51m
- Merged PRs (30d)
- 10
Description
**Package:** `AWSSDK.BedrockRuntime`
**Version:** 4.0.21.3 (latest as of June 2026)
**Runtime:** .NET 8
## Problem
Using `DocumentSource.S3Location` in a Bedrock `ConverseAsync` request causes the service to reject the request with a `ValidationException`:
```
Amazon.BedrockRuntime.Model.ValidationException: The model returned the following errors:
messages.0.content.4.document.source.type: Field required
```
## Reproduction
```csharp
var request = new ConverseRequest
{
Messages =
[
new Message
{
Role = ConversationRole.User,
Content =
[
new ContentBlock
{
Document = new DocumentBlock
{
Format = DocumentFormat.Pdf,
Name = "my-document",
Source = new DocumentSource
{
S3Location = new S3Location { Uri = "s3://my-bucket/my-file.pdf" }
}
}
}
]
}
],
ModelId = "..."
};
await bedrockClient.ConverseAsync(request); // throws ValidationException
```
## Root cause
The Bedrock service expects a `type` discriminator field (e.g. `"type": "s3"`) inside the `document.source` JSON object. The `DocumentSource` class in the .NET SDK has no `Type` property and the SDK does not serialize one — which is correct per the Smithy model, but the service rejects the request anyway.
The same issue was reported for the JS SDK in [aws-sdk-js-v3#7732](https://github.com/aws/aws-sdk-js-v3/issues/7732) (Feb 2026), where it was labeled `service-api problem`. However, it was closed without a fix, and the problem persists in the .NET SDK as well.
Notably, the [`DocumentSource` API reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_DocumentSource.html) does not list the .NET SDK as a supported language, suggesting this code path has never been validated for .NET.
## Expected behavior
Either:
- The service stops requiring the undocumented `type` field, or
- The SDK serializes the discriminator so the service accepts the request
## Workaround
Download the file locally and pass it via `DocumentSource.Bytes` instead of `S3Location`. This works but forces the caller to download and re-upload the file, adding latency and memory pressure.
Contributor guide
Research direction
Start at DocumentSource serialization used by ConverseAsync and compare the emitted document.source with the Bedrock request expected in the supplied S3Location reproduction. Determine whether the missing type can be addressed in the SDK or requires a service correction. Done means the request is accepted with S3Location, or the issue is confirmed and documented as service-side.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, csharp
- Domain
- api, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100