8000 fix CBOR datetime encoding by alexrashed · Pull Request #6791 · localstack/localstack · GitHub
[go: up one dir, main page]

Skip to content

fix CBOR datetime encoding #6791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 31, 2022
Merged

fix CBOR datetime encoding #6791

merged 4 commits into from
Aug 31, 2022

Conversation

alexrashed
Copy link
Member

In comparison to the typical JSON datetime format for AWS services (unixtimestamp, i.e. the float representation of the current unix timestamp seconds), for CBOR the unixtimestampmillis (basically the int representation of unixtimestamp * 1000) format is used.

This PR contains the following changes:

  • bdd1af3: Fixes the CBOR datetime encoding.
  • 4b16c7c: Fixes an issue with the forwarding of invalid requests. It disables the validation in the botoclient when creating the request which will be forwarded (because the backend should take care of the request parameter validation).
  • 3c0d807: Changes the loglevel of the serializer DEBUG logs to TRACE (since these are a bit verbose, but useful).

This PR fixes #6787.

The following AWS Java SDK snippet has been used to reproduce the issue (based on the issue report of @nicoloboschi):

import software.amazon.awssdk.core.SdkBytes;
import software.amazon.awssdk.services.kinesis.KinesisAsyncClient;
import software.amazon.awssdk.services.kinesis.model.*;

import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.Charset;
import java.util.Random;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

class KinesisCBOR {
    public static void main(String[] args) throws ExecutionException, InterruptedException, URISyntaxException {
        try (final KinesisAsyncClient client = KinesisAsyncClient.builder()
                .endpointOverride(new URI("http://localhost.localstack.cloud:4566")).build()) {
            Random rand = new Random();
            String streamName = "Test-Stream-" + rand.nextInt(10000);
            client.createStream(CreateStreamRequest.builder().streamName(streamName).shardCount(1).build()).get();
            TimeUnit.SECONDS.sleep(2);
            client.putRecord(PutRecordRequest.builder()
                    .streamName(streamName)
                    .data(SdkBytes.fromString("DATA", Charset.defaultCharset()))
                    .partitionKey("partitionkey")
                    .build()).get();
            final String shardId = client.listShards(ListShardsRequest.builder().streamName(streamName).build())
                    .get().shards().get(0).shardId();

            final String iterator = client.getShardIterator(GetShardIteratorRequest.builder()
                            .streamName(streamName)
                            .shardId(shardId)
                            .shardIteratorType(ShardIteratorType.TRIM_HORIZON)
                            .build()).get().shardIterator();
            final GetRecordsResponse response = client.getRecords(GetRecordsRequest.builder().shardIterator(iterator)
                                    .build()).get();
            System.out.println(response);
        }
    }
}

The fix has been validated with the Java snippet as well as with the extended integration test.

@alexrashed alexrashed requested a review from thrau as a code owner August 31, 2022 08:28
@alexrashed alexrashed temporarily deployed to localstack-ext-tests August 31, 2022 08:28 Inactive
@coveralls
Copy link
coveralls commented Aug 31, 2022

Coverage Status

Coverage increased (+0.0006%) to 91.393% when pulling 07201c0 on fix-cbor-datetime-encoding into df960fe on master.

@github-actions
Copy link
github-actions bot commented Aug 31, 2022

LocalStack integration with Pro

       3 files  ±0         3 suites  ±0   1h 24m 58s ⏱️ + 9m 42s
1 244 tests +1  1 203 ✔️ +1  41 💤 ±0  0 ±0 
1 669 runs  +1  1 597 ✔️ +1  72 💤 ±0  0 ±0 

Results for commit 07201c0. ± Comparison against base commit df960fe.

♻️ This comment has been updated with latest results.

Copy link
Member
@thrau thrau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for jumping on this so quickly @alexrashed! LGTM, just a minor comment related to creating the botocore Config object for every new request.

I can see that we're starting to create or own aws client ;-)

@alexrashed alexrashed temporarily deployed to localstack-ext-tests August 31, 2022 11:43 Inactive
@alexrashed alexrashed merged commit 591111c into master Aug 31, 2022
@alexrashed alexrashed deleted the fix-cbor-datetime-encoding branch August 31, 2022 13:42
macnev2013 pushed a commit to macnev2013/localstack that referenced this pull request Sep 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bug: not able to get records from kinesis with "latest" docker image
3 participants
0