question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Invalid pagination token given" on @key query

See original GitHub issue

Having a model with a key as following:

  @key(
    name: "byOrganization"
    fields: ["organizationID"]
    queryField: "merchantsByOrganizationID"
  )

has generated resource template as following:

## [Start] Set query expression for @key **
#set( $modelQueryExpression = {} )
#if( !$util.isNull($ctx.args.organizationID) )
  #set( $modelQueryExpression.expression = "#organizationID = :organizationID" )
  #set( $modelQueryExpression.expressionNames = {
  "#organizationID": "organizationID"
} )
  #set( $modelQueryExpression.expressionValues = {
  ":organizationID": {
      "S": "$ctx.args.organizationID"
  }
} )
#end
## [End] Set query expression for @key **
#set( $limit = $util.defaultIfNull($context.args.limit, 10) )
#set( $QueryRequest = {
  "version": "2017-02-28",
  "operation": "Query",
  "limit": $limit,
  "query": $modelQueryExpression,
  "index": "byOrganization"
} )
#if( !$util.isNull($ctx.args.sortDirection)
                    && $ctx.args.sortDirection == "DESC" )
  #set( $QueryRequest.scanIndexForward = false )
#else
  #set( $QueryRequest.scanIndexForward = true )
#end
#if( $context.args.nextToken ) #set( $QueryRequest.nextToken = $util.toJson($context.args.nextToken) ) #end
#if( $context.args.filter ) #set( $QueryRequest.filter = $util.parseJson("$util.transform.toDynamoDBFilterExpression($ctx.args.filter)") ) #end
$util.toJson($QueryRequest)

Do results in a error when applying a nextToken:

com.amazonaws.deepdish.common.pagination.InvalidPaginationTokenException: Invalid pagination token given.

Amplify CLI Version 4.13.4

Additional context Applying the fix in #3452 on https://github.com/aws-amplify/amplify-cli/blob/master/packages/graphql-key-transformer/src/KeyTransformer.ts#L850 solves the issue.

I believe #3459 might be the same bug but was closed as fixed.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
slatematescommented, Mar 2, 2020

It seems to work only when we use queries without any specific keys . For example

listJourneys (limit :5,nextToken :“sometoken”)

However if we were to use a query such as: listJourneys (journeyLong : true , limit:5 , nextToken :"sometoken) then it throws this error . We had the same issue at version 4.13.3 . However, 4.13.4 the issue seems to come up when using list queries on GSI . Please treat this as urgent as this is a blocker for us.

2reactions
kaustavghosh06commented, Mar 6, 2020

We released a fix for this with v4.14.1 today.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use the "nextToken" parameter to test Pagination?
nextToken is a String that you get in the response when you send a request, looks like. and it has nothing to do...
Read more >
Pagination error invalid token for Rest API Data Factory
Hi,. I am trying to use rest api to do pagination as it is just sending the first page in Azure ADF going...
Read more >
Paginating table query results - Amazon DynamoDB
DynamoDB paginates the results from Query operations. With pagination, the Query results are divided into "pages" of data that are 1 MB in...
Read more >
Token-based pagination - IBM Cloud Docs
The page token query parameter, which SHOULD be named start but MAY be named token , MUST be used to determine what resource...
Read more >
Storyblok API Documentation
To perform a GET request with your token append the query parameter token ... 401 - Unauthorized, No valid API key provided. ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found