Skip to content

"Unexpected Server Error" caused by a non-validated malformed payload for createIndex on a table #2442

@sl-at-ibm

Description

@sl-at-ibm

Missing validation for a payload such as: {"createIndex":{"name":"map_e_idx","definition":{}}}.
Resulting in an Unexpected Server Error from the Data API rather than a graceful message to the caller.

Observed as of today on prod Astra.

An unexpected server error occurred while processing the request. \n\nError Class: NullPointerException\nError Message: Cannot invoke "io.stargate.sgv2.jsonapi.api.model.command.table.definition.indexes.RegularIndexDefinitionDesc$RegularIndexColumn.columnName()" because the return value of "io.stargate.sgv2.jsonapi.api.model.command.table.definition.indexes.RegularIndexDefinitionDesc.column()" is null\n\nReview the Error Message before retrying this request.

Reproduction

1 Create table

curl -s -X POST \
    "$ASTRA_DB_API_ENDPOINT/api/json/v1/default_keyspace" \
    -H "Token: $ASTRA_DB_APPLICATION_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
    "createTable": {
        "name": "t",
        "definition": {
            "columns": {
                "id": "text",
                "map_e": {
                    "type": "map",
                    "keyType": "text",
                    "valueType": "text"
                }
            },
            "primaryKey": {
                "partitionBy": [
                    "id"
                ],
                "partitionSort": {}
            }
        }
    }
}'

returns

{"status":{"ok":1}}

2 Send the malformed payload

curl -s -X POST \
    "$ASTRA_DB_API_ENDPOINT/api/json/v1/default_keyspace/t" \
    -H "Token: $ASTRA_DB_APPLICATION_TOKEN" \
    -H "Content-Type: application/json" \
    -d '{
    "createIndex": {
        "name": "map_e_idx",
        "definition": {}
    }
}'

results in:

{
    "errors": [
        {
            "id": "dd8d1214-52b5-45af-8ca6-3c74da38d286",
            "family": "SERVER",
            "scope": "",
            "errorCode": "UNEXPECTED_SERVER_ERROR",
            "title": "Unexpected server error",
            "message": "An unexpected server error occurred while processing the request. \n\nError Class: NullPointerException\nError Message: Cannot invoke \"io.stargate.sgv2.jsonapi.api.model.command.table.definition.indexes.RegularIndexDefinitionDesc$RegularIndexColumn.columnName()\" because the return value of \"io.stargate.sgv2.jsonapi.api.model.command.table.definition.indexes.RegularIndexDefinitionDesc.column()\" is null\n\nReview the Error Message before retrying this request."
        }
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions