Repository navigation
Use peek to tell whether a response has a body in the smithy clients - #48
Open
alexey-milovidov wants to merge 1 commit into
Open
alexey-milovidov wants to merge 1 commit into
alexey-milovidov wants to merge 1 commit into
Conversation
ClickHouse gives the SDK a response body that is a stream over the HTTP session: it is only read from, and its `tellp` does not say whether there is anything in it. The legacy clients (`AWSXMLClient`, `AWSProtocolClient.h`) already ask `peek` instead. The clients that are generated on top of `smithy::client::AwsSmithyClientT`, such as the ones of Amazon Bedrock, do not go through that code: `JsonOutcomeSerializer` and `XmlOutcomeSerializer` took every successful response for an empty one, and the error marshallers took every error for one without a body, so its type was guessed from the status code and its message was `No response body.` Ask `peek` there as well: in the two serializers, and in `BuildAWSError` of `JsonErrorMarshaller`, `XmlErrorMarshaller` and `RpcV2ErrorMarshaller`, which only the smithy clients call. The clients that ClickHouse has built so far (S3, KMS, Glue) are legacy ones, so nothing changes for them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
alexey-milovidov
added a commit
to ClickHouse/ClickHouse
that referenced
this pull request
Dec 5, 2026
… for Amazon Bedrock The question was whether the provider can reuse the AWS SDK that is already linked: #137792 (comment) It can, in two ways. The requests are sent, signed and retried by `aws-cpp-sdk-core`, which `contrib/aws-cmake` builds anyway, over the HTTP client of ClickHouse. The provider of the AI SDK writes and reads the JSON of the Converse API itself (ClickHouse/ai-sdk-cpp#73), so none of the generated clients of `bedrock-runtime`, `bedrock` and `sts` is built: only the endpoint rules of the two services, 6 files instead of 290. The credentials of AWS are found by `S3::S3CredentialsProviderChain`, the chain that ClickHouse has for the other services of AWS, and given to the provider. The default chain of the AWS SDK is not linked for it. It also could not work here for a web identity token or for a profile with a role: it asks AWS STS through the HTTP client of the AWS Common Runtime, which ClickHouse builds without TLS. When there are no credentials, the client says where it has looked for them and sends nothing, instead of sending a request without a signature. The stripped `clickhouse` binary (aarch64, a reduced build with the AWS SDK) grows by 200,016 bytes with the provider instead of 1,465,336, and gets 2 more static initializers instead of 51. The mock of `06038_client_ai_bedrock_provider` now checks the signature of every signed request, the way a service of AWS does: from the path as it has arrived. It found that the path that was signed was not the path that was sent whenever the model has a colon, as nearly every model of Bedrock has: the AWS SDK signs a colon as it is, and `PocoHTTPClient` sends it encoded. It was so with the generated clients as well. The provider now asks the AWS SDK for the strict encoding, which is what `PocoHTTPClient` sends. The test also asks a model by its ARN, which needs the previous commit. `contrib/aws` is back at the commit of `master`: the patch of ClickHouse/aws-sdk-cpp#48 was for the generated clients. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ClickHouse gives the SDK a response body that is a stream over the HTTP session: it is only read from, and its
tellpdoes not say whether there is anything in it. The legacy clients (AWSXMLClient,AWSProtocolClient.h) are already patched in this fork to askpeekinstead.The clients that are generated on top of
smithy::client::AwsSmithyClientT, such as the ones of Amazon Bedrock, do not go through that code:JsonOutcomeSerializerandXmlOutcomeSerializertook every successful response for an empty one;No response body.This asks
peekthere as well: in the two serializers, and inBuildAWSErrorofJsonErrorMarshaller,XmlErrorMarshallerandRpcV2ErrorMarshaller, which only the smithy clients call.The clients that ClickHouse has built so far (S3, KMS, Glue) are legacy ones, so nothing changes for them. It is needed for the
bedrockprovider of the AI agent ofclickhouse-client, which is the first use of smithy clients in ClickHouse.Related: ClickHouse/ClickHouse#137792
🤖 Generated with Claude Code