Skip to content

AWS_CSM_ENABLED with DefaultMonitoring Does not work because Header Look Up is case-sensitive and fails to pick up a needed key #1536

Closed
@vinayan3

Description

@vinayan3

Confirm by changing [ ] to [x] below to ensure that it's a bug:

Describe the bug
A clear and concise description of what the bug is.
export AWS_CSM_ENABLED=true causes the SDK to assert.

/aws-cpp-sdk/aws-core/source/http/standard/StandardHttpRequest.cpp:73: virtual const String& Aws::Http::Standard::StandardHttpRequest::GetHeaderValue(const char*) const: Assertion `iter != headerMap.end()' failed.

SDK version number
1.7.211
Platform/OS/Hardware/Device
What are you running the sdk on? Linux/Ubuntu 18.04 Desktop/Dell XPS 15 9500

To Reproduce (observed behavior)
Steps to reproduce the behavior (please share code)

  1. Create a small client example which puts an object to S3.
  2. Before running binary set export AWS_CSM_ENABLED=true.
  3. See assert

Expected behavior
A clear and concise description of what you expected to happen.
No Assert

Logs/output
Stack Trace

#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x00007f3990252921 in __GI_abort () at abort.c:79
#2  0x00007f399024248a in __assert_fail_base (fmt=0x7f39903c9750 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x55e1a1ba87de "iter != headerMap.end()", file=file@entry=0x55e1a1ba8790 "third_party/aws-cpp-sdk/aws-core/source/http/standard/StandardHttpRequest.cpp", line=line@entry=73, function=function@entry=0x55e1a1ba8860 <Aws::Http::Standard::StandardHttpRequest::GetHeaderValue[abi:cxx11](char const*) const::__PRETTY_FUNCTION__> "virtual const String& Aws::Http::Standard::StandardHttpRequest::GetHeaderValue(const char*) const") at assert.c:92
#3  0x00007f3990242502 in __GI___assert_fail (assertion=0x55e1a1ba87de "iter != headerMap.end()", file=0x55e1a1ba8790 "third_party/aws-cpp-sdk/aws-core/source/http/standard/StandardHttpRequest.cpp", line=73, function=0x55e1a1ba8860 <Aws::Http::Standard::StandardHttpRequest::GetHeaderValue[abi:cxx11](char const*) const::__PRETTY_FUNCTION__> "virtual const String& Aws::Http::Standard::StandardHttpRequest::GetHeaderValue(const char*) const") at assert.c:101
#4  0x000055e1a1582923 in Aws::Http::Standard::StandardHttpRequest::GetHeaderValue[abi:cxx11](char const*) const (this=0x7f398fe3d410, headerName=0x55e1a1ba4b6e "X-Amz-Security-Token") at third_party/aws-cpp-sdk/aws-core/source/http/standard/StandardHttpRequest.cpp:73
#5  0x000055e1a157c746 in Aws::Http::HttpRequest::GetAwsSessionToken[abi:cxx11]() const (this=0x7f398fe3d410) at third_party/aws-cpp-sdk/aws-core/include/aws/core/http/HttpRequest.h:309
#6  0x000055e1a1579ea1 in Aws::Monitoring::FillOptionalApiAttemptFieldsToJson (json=..., request=0x7f398fe3d410, outcome=..., metricsFromCore=...) at third_party/aws-cpp-sdk/aws-core/source/monitoring/DefaultMonitoring.cpp:154
#7  0x000055e1a157b46e in Aws::Monitoring::DefaultMonitoring::CollectAndSendAttemptData (this=0x7f398fe633c0, serviceName="S3", requestName="PutObject", request=std::shared_ptr<const Aws::Http::HttpRequest> (use count 3, weak count 0) = {...}, outcome=..., metricsFromCore=..., context=0x7f398fe3fe10) at third_party/aws-cpp-sdk/aws-core/source/monitoring/DefaultMonitoring.cpp:273
#8  0x000055e1a157a924 in Aws::Monitoring::DefaultMonitoring::OnRequestSucceeded (this=0x7f398fe633c0, serviceName="S3", requestName="PutObject", request=std::shared_ptr<const Aws::Http::HttpRequest> (use count 3, weak count 0) = {...}, outcome=..., metricsFromCore=..., context=0x7f398fe3fe10) at third_party/aws-cpp-sdk/aws-core/source/monitoring/DefaultMonitoring.cpp:224
#9  0x000055e1a15704c0 in Aws::Monitoring::OnRequestSucceeded (serviceName="S3", requestName="PutObject", request=std::shared_ptr<const Aws::Http::HttpRequest> (use count 3, weak count 0) = {...}, outcome=..., metricsFromCore=..., contexts=std::vector of length 1, capacity 1 = {...}) at third_party/aws-cpp-sdk/aws-core/source/monitoring/MonitoringManager.cpp:60
#10 0x000055e1a15139b3 in Aws::Client::AWSClient::AttemptExhaustively (this=0x7f398fe5d2d0, uri=..., request=..., method=Aws::Http::HttpMethod::HTTP_PUT, signerName=0x55e1a1b9e980 <Aws::Auth::SIGV4_SIGNER> "SignatureV4") at third_party/aws-cpp-sdk/aws-core/source/client/AWSClient.cpp:187
#11 0x000055e1a1519df2 in Aws::Client::AWSXMLClient::MakeRequest (this=0x7f398fe5d2d0, uri=..., request=..., method=Aws::Http::HttpMethod::HTTP_PUT, signerName=0x55e1a1b9e980 <Aws::Auth::SIGV4_SIGNER> "SignatureV4") at third_party/aws-cpp-sdk/aws-core/source/client/AWSClient.cpp:797
#12 0x000055e1a12d5954 in Aws::S3::S3Client::PutObject (this=0x7f398fe5d2d0, request=...) at third_party/aws-cpp-sdk/aws-s3/source/S3Client.cpp:3290

Additional context
The reason this is happening is because the header's key is in lower case

headersMap = {
 ... 
"x-amz-security-token": "some value"
}

The value being looked up is

AWS_SECURITY_TOKEN = "X-Amz-Security-Token";

A case insensitive look up is needed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions