aws-sdk-cpp icon indicating copy to clipboard operation
aws-sdk-cpp copied to clipboard

AWS SDK for C++ cannot parse ISO 8601 timestamps with fractional seconds of more than 3 decimal digits

Open marcinsulikowski opened this issue 2 years ago • 1 comments

Describe the bug

ISO_8601DateParser::Parse accepts ISO 8601 timestamps with either no decimal seconds or with exactly three decimal digits (i.e., millisecond precision). In the latter case the fractional seconds are discarded by the parser.

Whereas allowing only three digits may be sufficient to parse AWS API responses, it causes problems when testing applications that use AWS SDK for C++ with mocks that create AWS API responses if those responses contain timestamps which are valid according to RFC 3339 but have 6 or 9 decimal digits. AWS SDKs in other languages (e.g., botocore) don't have such limitations so it seems the limitation of the AWS SDK for C++ is not intentional. It may also cause problems for existing C++ applications in the future, if any of AWS APIs start returning more precise timestamps.

Expected Behavior

DateTime("2022-10-01T12:00:00.000000Z", DateFormat::ISO_8601) returns a valid DateTime object.

Current Behavior

DateTime("2022-10-01T12:00:00.000000Z", DateFormat::ISO_8601) returns an invalid DateTime object (Jan 1, 1970).

Reproduction Steps

assert(DateTime("2022-10-01T12:00:00.000000Z", DateFormat::ISO_8601).WasParseSuccessful());

Possible Solution

Because the parser discards fractional parts of the seconds either way, it could handle more than 3 digits in the same way – see the attached PR #2131.

Additional Information/Context

Here's one of the problems caused by this limitation of the AWS SDK for C++: https://github.com/localstack/localstack/issues/6985

AWS CPP SDK version used

1.9.361

Compiler and Version used

g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

Operating System and version

Ubuntu 20.04

marcinsulikowski avatar Oct 07 '22 08:10 marcinsulikowski

Thanks for the PR, reviewing it and making sure it passes tests

jmklix avatar Oct 11 '22 18:10 jmklix

The attached PR #2131 was merged and landed in release 1.9.366.

marcinsulikowski avatar Mar 01 '23 15:03 marcinsulikowski

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.

github-actions[bot] avatar Mar 01 '23 15:03 github-actions[bot]