aws / aws-sdk-java

The official AWS SDK for Java 1.x (In Maintenance Mode, End-of-Life on 12/31/2025). The AWS SDK for Java 2.x is available here: https://github.com/aws/aws-sdk-java-v2/
https://aws.amazon.com/sdkforjava
Apache License 2.0
4.13k stars 2.83k forks source link

Validation error for nextToken in AWSSynthetics #2336

Closed alexbarnes closed 4 years ago

alexbarnes commented 4 years ago

The nextToken returned by getCanaryRuns is not valid for subsequent requests when fetching multiple pages of data.

Expected Behavior

The returned nextToken should match the regular expression ^[a-zA-Z0-9=/+_.-]{4,252}$ to be valid for subsequent calls.

Current Behavior

The actual returned token is NextToken":"2020-05-24T04:03:39.000Z" or similar. Using this in a subsequent request gives the following error:

com.amazonaws.services.synthetics.model.ValidationException: 1 validation error detected: Value '2020-05-24T05:48:55.000Z' at 'nextToken' failed to satisfy constraint: Member must satisfy regular expression pattern: ^[a-zA-Z0-9=/+_.-]{4,252}$ (Service: AWSSynthetics; Status Code: 400; Error Code: ValidationException; Request ID: 4d4ef7b8-c4f9-4290-9515-d5c951a69ede; Proxy: null)

The wire logs are as follows:

> 2020.05.23 22:49:06.086 DEBUG main org.apache.http.wire http-outgoing-0 >> "POST /canary/<canary-name>/runs HTTP/1.1[\r][\n]"
> 2020.05.23 22:49:06.086 DEBUG main org.apache.http.wire http-outgoing-0 >> "Host: synthetics.us-west-2.amazonaws.com[\r][\n]"
> 2020.05.23 22:49:06.086 DEBUG main org.apache.http.wire http-outgoing-0 >> "amz-sdk-invocation-id: 438d06bd-f306-3187-e555-6a36d2fb0212[\r][\n]"
> 2020.05.23 22:49:06.086 DEBUG main org.apache.http.wire http-outgoing-0 >> "amz-sdk-request: attempt=1;max=4[\r][\n]"
> 2020.05.23 22:49:06.086 DEBUG main org.apache.http.wire http-outgoing-0 >> "amz-sdk-retry: 0/0/500[\r][\n]"
> 2020.05.23 22:49:06.086 DEBUG main org.apache.http.wire http-outgoing-0 >> "Authorization: AWS4-HMAC-SHA256 Credential=<removed>/us-west-2/synthetics/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-date, Signature=7b1b00465dc09ae1b95ac9318319a9911fb4cedc38250aa0e66d4105fb3e81b5[\r][\n]"
> 2020.05.23 22:49:06.087 DEBUG main org.apache.http.wire http-outgoing-0 >> "Content-Type: [\r][\n]"
> 2020.05.23 22:49:06.087 DEBUG main org.apache.http.wire http-outgoing-0 >> "User-Agent: aws-sdk-java/1.11.789 Mac_OS_X/10.14.6 OpenJDK_64-Bit_Server_VM/25.222-b10 java/1.8.0_222 groovy/2.5.4 vendor/AdoptOpenJDK[\r][\n]"
> 2020.05.23 22:49:06.087 DEBUG main org.apache.http.wire http-outgoing-0 >> "X-Amz-Date: 20200524T054905Z[\r][\n]"
> 2020.05.23 22:49:06.087 DEBUG main org.apache.http.wire http-outgoing-0 >> "Content-Length: 16[\r][\n]"
> 2020.05.23 22:49:06.087 DEBUG main org.apache.http.wire http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"
> 2020.05.23 22:49:06.087 DEBUG main org.apache.http.wire http-outgoing-0 >> "[\r][\n]"
> 2020.05.23 22:49:06.087 DEBUG main org.apache.http.wire http-outgoing-0 >> "{"MaxResults":1}"
> 2020.05.23 22:49:06.544 DEBUG main org.apache.http.wire http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"
> 2020.05.23 22:49:06.544 DEBUG main org.apache.http.wire http-outgoing-0 << "Date: Sun, 24 May 2020 05:49:06 GMT[\r][\n]"
> 2020.05.23 22:49:06.544 DEBUG main org.apache.http.wire http-outgoing-0 << "Content-Type: application/json[\r][\n]"
> 2020.05.23 22:49:06.545 DEBUG main org.apache.http.wire http-outgoing-0 << "Content-Length: 348[\r][\n]"
> 2020.05.23 22:49:06.545 DEBUG main org.apache.http.wire http-outgoing-0 << "Connection: keep-alive[\r][\n]"
> 2020.05.23 22:49:06.545 DEBUG main org.apache.http.wire http-outgoing-0 << "x-amzn-RequestId: dbe6b26f-ed20-48fd-8f47-3c814a8ee86b[\r][\n]"
> 2020.05.23 22:49:06.545 DEBUG main org.apache.http.wire http-outgoing-0 << "x-amz-apigw-id: NBag3EmaPHcFRpQ=[\r][\n]"
> 2020.05.23 22:49:06.545 DEBUG main org.apache.http.wire http-outgoing-0 << "X-Amzn-Trace-Id: Root=1-5eca0ad2-9f1026e012cfea20e9f15520[\r][\n]"
> 2020.05.23 22:49:06.545 DEBUG main org.apache.http.wire http-outgoing-0 << "[\r][\n]"
> 2020.05.23 22:49:06.545 DEBUG main org.apache.http.wire http-outgoing-0 << "{"CanaryRuns":[{"ArtifactS3Location":"bucket-name/canary/canary-name/successes/2020/05/24/05/48-54-949","Name":"canary-name","Status":{"State":"PASSED","StateReason":"","StateReasonCode":""},"Timeline":{"Completed":1.590299335E9,"Started":1.590299335E9}}],"NextToken":"2020-05-24T05:48:55.000Z"}"

Steps to Reproduce

Simple test for this (needs credentials and a region):

AWSSynthetics client = AWSSyntheticsClientBuilder.standard().build();
GetCanaryRunsResult result = new GetCanaryRunsResult();
do {
  result = client.getCanaryRuns(new GetCanaryRunsRequest().withName("my-canary").withNextToken(result.getNextToken()).withMaxResults(1));
} while (StringUtils.isNotEmpty(result.getNextToken()));

Your Environment

debora-ito commented 4 years ago

@alexbarnes thank you for reporting this issue, I'm able to reproduce.

The nextToken is being sent by the service API, so I'll pass your findings to the team behind the Synthetics API. I will keep you updated.

alexbarnes commented 4 years ago

Thanks @debora-ito. Do you have any updates on this issue? It's currently blocking the development of a feature I'm working on which uses this API and it would be great to know when I might be able to start work again.

debora-ito commented 4 years ago

@alexbarnes The service team removed the validation. I ran a quick test calling get-canary-runs in aws-cli and I don't see the error anymore. Can you check if it's working on your side?

debora-ito commented 4 years ago

Will be closing this issue soon if there's no updates.

alexbarnes commented 4 years ago

Apologies for the delay @debora-ito . I just tested this using my steps above and can confirm that this is now working as expected.

Thank you for the quick turnaround.