stargate / data-api

JSON document API for Apache Cassandra (formerly known as JSON API)
https://stargate.io
Apache License 2.0
14 stars 16 forks source link

[Tables] Passing empty `sort={}` and a pageState to a find results in "pageState is not supported with sort clause." error #1736

Open hemidactylus opened 4 days ago

hemidactylus commented 4 days ago

When running e.g. the second page of a find command, thus passing a pageState: <string> to the options, it is sufficient to provide an empty sort: {} to trigger the following error (the find being otherwise working correctly):

    "errors": [
        {
            "message": "Request invalid: field 'command.options.pageState' value
 \"FindCommand[filterClause=FilterClause[logicalExpression=LogicalExpression
{logicalRelation='AND', totalComparisonExpressionCount=2, logicalExpressions=[], 
comparisonExpressions=[ComparisonExpression{path='p_ascii', filterOperations=
[ValueComparisonOperation[operator=EQ, operand=JsonLiteral{type=STRING, 
value(String)=A}]], dbFilters=null}, ComparisonExpression{path='p_bigint', 
filterOperations=[ValueComparisonOperation[operator=EQ, operand=JsonLiteral
{type=NUMBER, value(BigDecimal)=100}]], dbFilters=null}]}], projectionDefinition=null, 
sortClause=SortClause[sortExpressions=[]], options=Options[limit=null, skip=null, 
pageState=AAgABAAAABMBAPB////r8H///+s=, includeSimilarity=false, includeSortVector=false]]\" 
not valid. Problem: pageState is not supported with sort clause.",
            "errorCode": "COMMAND_FIELD_INVALID",
            "id": "f18f73b3-3fa5-4d3c-ad17-ccfe21affd9b",
            "family": "REQUEST",
            "title": "Request invalid",
            "scope": "EMPTY"
        }
    ]
amorton commented 2 days ago

@hemidactylus this is a bug we need to fix, do you have an example of what the find was ?

hemidactylus commented 2 days ago

Sure, I just found this is enough even on an empty table and with a made-up pageState:

{
    "find": {
        "sort": {},
        "options": {
            "pageState": "x"
        }
    }
}
amorton commented 18 hours ago

Steps to reproduce with a table (not tested,but also happen with collections):

first query, works, gets rows and a next page state

{
    "find": {
        "sort": {}

    }
}

Run second query, with the page state from the first response. Note above has this, but us made up page state.

{
    "find": {
        "sort": {},
        "options": {
            "pageState": "FWxlby5tb29yZUBhd2Vzb21lLmFwaQDwf///6wA="
        }
    }
}

returns error:

{
    "errors": [
        {
            "message": "Request invalid: field 'command.options.pageState' value \"FindCommand[filterClause=null, projectionDefinition=null, sortClause=SortClause[sortExpressions=[]], options=Options[limit=null, skip=null, pageState=FWxlby5tb29yZUBhd2Vzb21lLmFwaQDwf///6wA=, includeSimilarity=false, includeSortVector=false]]\" not valid. Problem: pageState is not supported with sort clause.",
            "errorCode": "COMMAND_FIELD_INVALID",
            "id": "9a204ed0-2d10-4e19-9f1d-d28a5d2132c3",
            "title": "Request invalid",
            "family": "REQUEST",
            "scope": "EMPTY"
        }
    ]
}

error msg

Request invalid: field 'command.options.pageState' value "FindCommand[filterClause=null, projectionDefinition=null, sortClause=SortClause[sortExpressions=[]], options=Options[limit=null, skip=null, pageState=FWxlby5tb29yZUBhd2Vzb21lLmFwaQDwf///6wA=, includeSimilarity=false, includeSortVector=false]]" not valid. Problem: pageState is not supported with sort clause.

amorton commented 17 hours ago

Related to #1735