aws / aws-sdk

Landing page for the AWS SDKs on GitHub
https://aws.amazon.com/tools/
Other
68 stars 13 forks source link

DLM/GetLifecyclePolicy fails to parse timestamps #504

Closed SimonMachine closed 1 year ago

SimonMachine commented 1 year ago

Describe the bug

When trying to get a snapshot lifecycle policy using the ''dlmClient' and 'getLifecyclePolicy' method, get an unexpected exception regarding date parse.

Expected Behavior

dlmClient can parse the timestamp and get the policy object.

Current Behavior

error log: Unable to unmarshall response (Text '1.655421227201E9' could not be parsed at index 0). Response Code: 200, Response Text: OK

('1655421227.201E9' is the time when I created the dlm policy. )

Reproduction Steps

Create a Snapshot lifecycle policy from the aws console. Use the aws java sdk to fetch it using the getLifecyclePolicy method.

AwsBasicCredentials awsCredentials = AwsBasicCredentials.create(accessKey, secretKey);
DlmClientBuilder dlmClientBuilder = DlmClient.builder()
        .credentialsProvider(StaticCredentialsProvider.create(awsCredentials))
        .region(Region.of(region));
DlmClient client = dlmClientBuilder.build();
GetLifecyclePolicyRequest getLifecyclePolicyRequest=GetLifecyclePolicyRequest.builder().policyId(policyId).build();
GetLifecyclePolicyResponse lifecyclePolicy = client.getLifecyclePolicy(getLifecyclePolicyRequest);

Possible Solution

No response

Additional Information/Context

similar issue: 1053

AWS Java SDK version used

2.20.28

JDK version used

corretto-17.0.6

Operating System and version

windows server 2019

debora-ito commented 1 year ago

Hi @SimonMachine thank you for the callout, I can reproduce the error.

According to the service model, the timestamp should be iso8601:

https://github.com/aws/aws-sdk-java-v2/blob/4c1e3f6a5369648fc4045221c679484022b62e3e/services/dlm/src/main/resources/codegen-resources/service-2.json#L1183-L1186

and the service is sending 1.655421227201E9 in the response.

And the "timestampFormat":"iso8601" trait was added to the model in Feb 2019, probably to fix the previous issue - https://github.com/aws/aws-sdk-java-v2/issues/1053.

I'll reach out to the DLM service team.

debora-ito commented 1 year ago

The DLM is investigating the root cause.

Since this is an issue on the service side, it may impact other SDKs, so I'm transferring this to the aws-sdk repo for visibility.

I'll update here with any new info.

SimonMachine commented 1 year ago

hello,team, is there any update for this issue ?

debora-ito commented 1 year ago

@SimonMachine the DLM team released a fix, getLifecyclePolicy should be working now. Please check it out and let us know of any further question.

    "Policy": {
        "PolicyId": "policy-xxx",
        "Description": "My policy test",
        "State": "DISABLED",
        "StatusMessage": "DISABLED",
        "ExecutionRoleArn":  xxx,
        "DateCreated": "2023-03-27T21:43:40.716000+00:00",
        "DateModified": "2023-03-27T21:43:40.782000+00:00",
        ...
github-actions[bot] commented 1 year ago

This issue is now closed.

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.