amplify-cli: nextToken not accepted and gives error "Invalid pagination token given"
Describe the bug Query is working in development and build environments but when deployed in the Test environment the nextToken is never accepted.
The same error occurs in the code as well as the AppSync console where we do a query with a limit and get a nextToken. Then we do a query straight away with the same token and it gives the following error: com.amazonaws.deepdish.common.pagination.InvalidPaginationTokenException: Invalid pagination token given.
To Reproduce Do following query in the console (same as in the code) FYI There are 15 items in the table.
{
listUsers(limit:3){
items{
name
}
nextToken
}
}
The response is:
{
"data": {
"listUsers": {
"items": [
{
"name": "Joergen Von Klopp"
},
{
"name": "Yolanda McAdams"
},
{
"name": "Info Test"
}
],
"nextToken": "eyJ2ZX...shortened="
}
}
}
Then we do it again with the nextToken:
{
listUsers(limit:3,nextToken:"eyJ2ZX...shortened="){
items{
name
}
nextToken
}
}
The error is:
{
"data": {
"listUsers": null
},
"errors": [
{
"path": [
"listUsers"
],
"data": null,
"errorType": "DynamoDB:UserIllegalArgumentException",
"errorInfo": null,
"locations": [
{
"line": 2,
"column": 3,
"sourceName": null
}
],
"message": "com.amazonaws.deepdish.common.pagination.InvalidPaginationTokenException: Invalid pagination token given."
}
]
}
We experience the same behavior with all the tables in this environment. If we increase the limit we of course get all the elements but for some reason nextToken does not work.
Expected behavior Should get more data returned like on the other environments.
Screenshots If applicable, add screenshots to help explain your problem.
Environment
npx envinfo --system --binaries --browsers --npmPackages --npmGlobalPackages
npx: installed 1 in 1.301s
System:
OS: Windows 10 10.0.18362
CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
Memory: 8.41 GB / 23.94 GB
Binaries:
Node: 12.13.1 - C:\Tools\nodejs\node.EXE
npm: 6.13.2 - C:\Tools\nodejs\npm.CMD
Browsers:
Edge: 44.18362.449.0
Internet Explorer: 11.0.18362.1
Additional context Amplify --version 4.5.0 “aws-amplify”: “^2.2.2”, “aws-amplify-react”: “^3.1.3”,
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 48 (9 by maintainers)
Commits related to this issue
- fix(graphql-dynamodb-transformer): prevent doble escape of nextToken Updated the resolver code not to escape nextToken in list resolver since the response object as a whole gets sanitized fix #3411 — committed to yuth/amplify-cli by yuth 4 years ago
- fix(graphql-dynamodb-transformer): prevent doble escape of nextToken (#3452) Updated the resolver code not to escape nextToken in list resolver since the response object as a whole gets sanitized ... — committed to aws-amplify/amplify-cli by yuth 4 years ago
i also experience this error.
use this query on aws console
console return
then
console return
This is still happening for me on 4.13.4
I am also coming across this error when using next token for pagination. This seems to have began after I pushed to my development environment the same day this ticket was raised (The error wasn’t spotted until today). This push included a two field change to a table in my graphql schema, where said fields had their type changed from ‘[String]!’ to ‘AWSJSON!’. Interestingly, the now failing query that uses next token for pagination reads from a different table than that which was changed.
I am using Cognito user groups for authentication, and I can provide full schema if necessary.
Here is the error that I have captured in the AppSync console:
And here is the query req vtl in question (not quite as tidy as the gentleman above):
And the res vtl:
$util.toJson($ctx.result)
Has anyone rebuilt their environment from scratch to see if this fixes it? I would prefer not to have to do this, but when in doubt…
Just a bit of info, I was running into this as well after I upgraded from amplify-cli 4.13.1 to 4.13.2. Once I downgraded to 4.13.1 and did another
amplify push
life was better.We’ve root-caused the issue with the latest release and working on a fix for this which will be released soon. cc: @yuth
In an earlier version of the Amplify CLI a bug was introduced which double encoded the payload toJSON. What I suspect is you might have overridden the template when the CLI had the bug, which got you the buggy resolver. This was fixed in the CLI later, but since the template was overriden, that fix not propagate to that template.
Hello, I’m having this issue with amplify 4.25.0.
Hello, This issue is back with the latest (4.18.1) Amplify CLI Version. Overriding the version with 4.16.1 (which is the one I happen to know is working) as described at https://docs.aws.amazon.com/amplify/latest/userguide/custom-build-image.html#setup-live-updates no longer throws this error.
I just wanted to confirm that I had this issue with 4.13.3 but upgrading to 4.13.4 resolve it for me. The steps I took were:
Upgraded to 4.13.4 . The issue is resolved .Thanks
On Fri, 21 Feb 2020, 03:03 Andrew Panagos, notifications@github.com wrote:
I just upgraded to version 4.13.4 and things appear to be working for me as well. I’ll keep folks posted if otherwise. Thanks!
@kaustavghosh06 Please note we (i.e., myself and @AshwiniRaysecur )have tested publishing our app with version 4.13.4 and the issue seems to be resolved. Smoke tests show our app once again behaves as expected.
I attempted to build the application again from scratch, and still getting the pagination error for Amplify version 4.13.3
The resolver generated ‘Query.listSecurSamples.req.vtl’ file:
Worked correctly after downgrading to Amplify version 4.13.0
As per @a-j-olly’s comment above, can confirm it works when I downgraded the cli from
4.13.2
to4.13.0
and doamplify push
.@malcomm For me, this issue was occurring on CLI version 4.13.1, however once I downgraded to 4.13.0 it cleared up. I did try and upgrade to 4.13.2 to see if that might be a fix, but I could still reproduce the error.
@olivoil I’d recommend taking the CLI down to 4.13.0 and then doing a
amplify push
and see if that works.Hopefully the Amplify team can get to the bottom of this, but I have a work around for now.
Having the same issue with the latest CLI version (4.13.3) on any
@model
list query. Forcing version 4.13.1 of the CLI in build settings -> Live package updates does not seem to solve it for me, and I could not test 4.13.0 as there’s another issue with this version that was fixed in 4.13.1It happens with any
@model
, and is reproducible directly from the AppSync Console.Generate a simple
@model
Create a few objects, and query them, copying the value of nextToken verbatim from a previous query directly in AppSync Console
The error shows up consistently