GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing github.com — Fix RPC v2 CBOR timestamp parsing for float by bentsku · Pull Request #13541 · localstack/localstack
This repository was archived by the owner on Mar 23, 2026. It is now read-only.
Conversation
Contributor
MotivationAs reported with #13538, we have an issue parsing CBOR datetime values that are encoded as float. In CBOR, datetime values can encoded as different major types: integer and float (0, 1, 7, 25, 26, 27). See: We missed it in our testing that the Java SDK v2 would encode outgoing values as Double with Length 8 (27 major type). This PR also removes the spec patches that are not relevant anymore since the last ASF update, as the new CloudWatch spec contains the switch and the needed changes to support ChangesThe fix is to not delegate the usual datetime parsing to the base parser, as the Smithy specs are pretty adamant that CBOR has its own handling. Instead, we now make sure we cap the maximum precision to millisecond, and parse the incoming timestamp normally. I've done additional testing with the Java SDK v2 to make sure it is now able to send requests and receive our responses without issues. TestsI've done extensive testing, and also added Java SDK v2 tests, can be found attached. Not sure how reproducible they are as I'm running them in the context of the LocalStack Utils Java library, but I could confirm I was having the same issue as reported before, and now it works. Details
package cloud.localstack.awssdkv2; import org.junit.Assert; import org.junit.Test; import software.amazon.awssdk.auth.credentials.AwsBasicCredentials; import software.amazon.awssdk.auth.credentials.StaticCredentialsProvider; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.cloudwatch.model.*; import software.amazon.awssdk.services.cloudwatch.CloudWatchClient; import java.time.Instant; import java.time.ZoneOffset; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.ArrayList; import java.net.URI; import java.util.List; public class BasicFeaturesSDKV2Test { @Test public void testCWPutMetrics() throws Exception { final CloudWatchClient cwClient = CloudWatchClient.builder() .credentialsProvider(StaticCredentialsProvider.create( AwsBasicCredentials.create("test", "test"))) .region(Region.of("us-east-1")) .endpointOverride(URI.create("http://localhost.localstack.cloud:4566")) .build(); Dimension dimension = Dimension.builder() .name("UNIQUE_PAGES") .value("URLS") .build(); // Set an Instant object String time = ZonedDateTime.now( ZoneOffset.UTC ).format( DateTimeFormatter.ISO_INSTANT ); Instant instant = Instant.parse(time); double dataPoint = 1.23423; MetricDatum datum = MetricDatum.builder() .metricName("PAGES_VISITED") .unit(StandardUnit.NONE) .value(dataPoint) .timestamp(instant) // .dimensions(dimension) .build(); PutMetricDataRequest request = PutMetricDataRequest.builder() .namespace("SITE/TRAFFIC") .metricData(datum).build(); PutMetricDataResponse response = cwClient.putMetricData(request); Assert.assertNotNull(response); // GetMetricDataRequest request2 = GetMetricDataRequest.builder() // Set the current time and date range for metric query. Instant nowDate = Instant.now(); long hours = 1; long minutes = 30; Instant startTime = nowDate.minus(5, ChronoUnit.MINUTES); Instant endTime = nowDate.plus(hours, ChronoUnit.HOURS).plus(minutes, ChronoUnit.MINUTES); Metric met = Metric.builder() .metricName("PAGES_VISITED") .namespace("SITE/TRAFFIC") .build(); MetricStat metStat = MetricStat.builder() .stat("Sum") .period(60) // Assuming period in seconds .metric(met) .build(); MetricDataQuery dataQuery = MetricDataQuery.builder() .metricStat(metStat) .id("foo2") .returnData(true) .build(); List<MetricDataQuery> dq = new ArrayList<>(); dq.add(dataQuery); GetMetricDataRequest getMetricDataRequest = GetMetricDataRequest.builder() // .maxDatapoints(10) // .scanBy(ScanBy.TIMESTAMP_DESCENDING) .startTime(startTime) .endTime(endTime) .metricDataQueries(dq) .build(); // Call the async method for CloudWatch data retrieval. GetMetricDataResponse responseGetData = cwClient.getMetricData(getMetricDataRequest); Assert.assertNotNull(responseGetData); System.out.println(responseGetData.metricDataResults()); } } Related
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
1 task done
alexrashed
approved these changes
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! Great catch with the timestamp precision, and really nice to see this being explicitly covered in an AWS validated snapshot test! 💯 🦸🏽 🐛 🔨
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: Nice to see the patches introduced with #13103 are removed here since the official specs in
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. praise: Whoof, great catch!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
S3 Image Test Results (AMD64 / ARM64) 2 files 2 suites 8m 12s ⏱️ Results for commit ffd14ad. ♻️ This comment has been updated with latest results. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Test Results - Preflight, Unit22 982 tests +1 21 140 ✅ +1 6m 4s ⏱️ -5s Results for commit ffd14ad. ± Comparison against base commit 14d1ccb. ♻️ This comment has been updated with latest results. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Test Results (amd64) - Acceptance7 tests ±0 5 ✅ ±0 2m 59s ⏱️ -3s Results for commit ffd14ad. ± Comparison against base commit 14d1ccb. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Test Results - Alternative Providers180 tests - 1 288 39 ✅ - 848 2m 29s ⏱️ - 30m 40s Results for commit ffd14ad. ± Comparison against base commit 14d1ccb. This pull request removes 1288 tests. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Test Results (amd64) - Integration, Bootstrap 5 files ±0 5 suites ±0 2h 34m 54s ⏱️ - 1m 12s Results for commit ffd14ad. ± Comparison against base commit 14d1ccb. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
LocalStack Community integration with Pro 2 files ±0 2 suites ±0 1h 55m 8s ⏱️ +31s Results for commit ffd14ad. ± Comparison against base commit 14d1ccb. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
bug: Cloutwatch PutMetricData fails with AWS Java SDK 2.40.10
There was an error while loading. Please reload this page.