cardano-foundation / cardano-graphql

GraphQL API for Cardano
Apache License 2.0
262 stars 104 forks source link

Cannot return null for non-nullable field Token.asset. #904

Open zxpectre opened 3 hours ago

zxpectre commented 3 hours ago

Summary

It seems to me like a legacy issue appeared again on this last release @Kammerlo. Happened on preprod.

Issue is theres nothing wrong with the query nor with the chain so replying 200 http code for internal errors breaks the wallet in our case. I have the feeling that there is a lag between the indexer and background service while trying to process assets. Tested on several of our nodes, all of them are failing the same way for some minutes.

Steps to reproduce the bug

How to replicate:

Query:


  fragment _UTXOs on Query {
    utxos(
      #distinct_on:$distinct_on
      #limit:$limit
      #order_by:$order_by
      #offset:$offset
      where:$where
    ){

  txHash
  address
  index
  #transaction
  tokens{
    quantity
    asset{

  assetId
  assetName
  fingerprint
  policyId
  # name

    }
  }
  value

    }
  }

  fragment _GetProtocolParams on Query {
    epochs(
      limit:1
      order_by:{number:desc}
    ){
      number
      protocolParams{
        coinsPerUtxoByte
      }
    }
    genesis{
        alonzo{
            maxValueSize
            lovelacePerUTxOWord

            executionPrices{
              prSteps {numerator denominator}
              prMem  {numerator denominator}
            }
            maxTxExUnits{
              exUnitsMem
              exUnitsSteps
            }
            maxBlockExUnits{
              exUnitsMem
              exUnitsSteps
            }
            collateralPercentage
            maxCollateralInputs

        }
        shelley{
            protocolParams{
                poolDeposit
                keyDeposit
                minUTxOValue
                minFeeA
                minFeeB
                maxTxSize
            }  
        }
    }
  }

  fragment _GetTip on Query {
    cardano {
      tip {
        number
        slotNo
        slotInEpoch
        epochNo
        forgedAt
      }
    }
  }

  query PaymentAddresses($where: TransactionOutput_bool_exp){

    ..._GetTip
    ..._GetProtocolParams
    ..._UTXOs
  }

variables:

{
    "where": {
        "address": {
            "_eq": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq"
        }
    }
}

Actual Result

200 http response breaking our client side code (probably Graphql Apollo don't like this response):


{
  "errors": [
    {
      "message": "Cannot return null for non-nullable field Token.asset.",
      "locations": [
        {
          "line": 8,
          "column": 7
        }
      ],
      "path": [
        "utxos",
        6,
        "tokens",
        1,
        "asset"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: Cannot return null for non-nullable field Token.asset.",
            "    at completeValue (/app/node_modules/graphql/execution/execute.js:560:13)",
            "    at completeValueCatchingError (/app/node_modules/graphql/execution/execute.js:495:19)",
            "    at resolveField (/app/node_modules/graphql/execution/execute.js:435:10)",
            "    at executeFields (/app/node_modules/graphql/execution/execute.js:275:18)",
            "    at collectAndExecuteSubfields (/app/node_modules/graphql/execution/execute.js:713:10)",
            "    at completeObjectValue (/app/node_modules/graphql/execution/execute.js:703:10)",
            "    at completeValue (/app/node_modules/graphql/execution/execute.js:591:12)",
            "    at completeValue (/app/node_modules/graphql/execution/execute.js:557:21)",
            "    at completeValueCatchingError (/app/node_modules/graphql/execution/execute.js:495:19)",
            "    at /app/node_modules/graphql/execution/execute.js:618:25"
          ]
        }
      }
    }
  ],
  "data": {
    "cardano": {
      "tip": {
        "number": 2928016,
        "slotNo": "76974899",
        "slotInEpoch": "424499",
        "epochNo": 181,
        "forgedAt": "2024-11-26T21:54:59Z"
      }
    },
    "epochs": [
      {
        "number": 181,
        "protocolParams": {
          "coinsPerUtxoByte": "4310"
        }
      }
    ],
    "genesis": {
      "alonzo": {
        "maxValueSize": 5000,
        "lovelacePerUTxOWord": 34482,
        "executionPrices": {
          "prSteps": {
            "numerator": 721,
            "denominator": 10000000
          },
          "prMem": {
            "numerator": 577,
            "denominator": 10000
          }
        },
        "maxTxExUnits": {
          "exUnitsMem": "10000000",
          "exUnitsSteps": "10000000000"
        },
        "maxBlockExUnits": {
          "exUnitsMem": "50000000",
          "exUnitsSteps": "40000000000"
        },
        "collateralPercentage": 150,
        "maxCollateralInputs": 3
      },
      "shelley": {
        "protocolParams": {
          "poolDeposit": 500000000,
          "keyDeposit": 2000000,
          "minUTxOValue": 1000000,
          "minFeeA": 44,
          "minFeeB": 155381,
          "maxTxSize": 16384
        }
      }
    },
    "utxos": [
      {
        "txHash": "521744ef72109ec354da176c818f1f4ea77823144313385df39d8d75a168a54f",
        "address": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq",
        "index": 6,
        "tokens": [],
        "value": "5000000"
      },
      {
        "txHash": "521744ef72109ec354da176c818f1f4ea77823144313385df39d8d75a168a54f",
        "address": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq",
        "index": 5,
        "tokens": [],
        "value": "5000000"
      },
      {
        "txHash": "521744ef72109ec354da176c818f1f4ea77823144313385df39d8d75a168a54f",
        "address": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq",
        "index": 4,
        "tokens": [],
        "value": "40000000"
      },
      {
        "txHash": "521744ef72109ec354da176c818f1f4ea77823144313385df39d8d75a168a54f",
        "address": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq",
        "index": 3,
        "tokens": [],
        "value": "40000000"
      },
      {
        "txHash": "521744ef72109ec354da176c818f1f4ea77823144313385df39d8d75a168a54f",
        "address": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq",
        "index": 2,
        "tokens": [],
        "value": "80000000"
      },
      {
        "txHash": "521744ef72109ec354da176c818f1f4ea77823144313385df39d8d75a168a54f",
        "address": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq",
        "index": 1,
        "tokens": [],
        "value": "80000000"
      },
      null
    ]
  }
}

Expected Result

http 200

{
  "data": {
    "cardano": {
      "tip": {
        "number": 2928200,
        "slotNo": "76979452",
        "slotInEpoch": "429052",
        "epochNo": 181,
        "forgedAt": "2024-11-26T23:10:52Z"
      }
    },
    "epochs": [
      {
        "number": 181,
        "protocolParams": {
          "coinsPerUtxoByte": "4310"
        }
      }
    ],
    "genesis": {
      "alonzo": {
        "maxValueSize": 5000,
        "lovelacePerUTxOWord": 34482,
        "executionPrices": {
          "prSteps": {
            "numerator": 721,
            "denominator": 10000000
          },
          "prMem": {
            "numerator": 577,
            "denominator": 10000
          }
        },
        "maxTxExUnits": {
          "exUnitsMem": "10000000",
          "exUnitsSteps": "10000000000"
        },
        "maxBlockExUnits": {
          "exUnitsMem": "50000000",
          "exUnitsSteps": "40000000000"
        },
        "collateralPercentage": 150,
        "maxCollateralInputs": 3
      },
      "shelley": {
        "protocolParams": {
          "poolDeposit": 500000000,
          "keyDeposit": 2000000,
          "minUTxOValue": 1000000,
          "minFeeA": 44,
          "minFeeB": 155381,
          "maxTxSize": 16384
        }
      }
    },
    "utxos": [
      {
        "txHash": "600dedbb30cb08d7bfbfa032d7db1976c72431e4bef4c9de28b654f948cd082c",
        "address": "addr_test1qrw63s3htsvy529ljllpy5t74ur7ufckfjxqzjdmpg45mz9dqwj2u3djrag0mene2cm9elu5mdqmcz9zc2rzgq7c5g6qjkpklq",
        "index": 1,
        "tokens": [
          {
            "quantity": "1",
            "asset": {
              "assetId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb47616d654368616e6765724e4654202331",
              "assetName": "47616d654368616e6765724e4654202331",
              "fingerprint": "asset18s56zxyw38tenrvercykj4xp754ul53ytnpglw",
              "policyId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb"
            }
          },
          {
            "quantity": "1",
            "asset": {
              "assetId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb47616d654368616e6765724e4654202332",
              "assetName": "47616d654368616e6765724e4654202332",
              "fingerprint": "asset1y033c4hpn5g235urf25jyu5tvp3qfam7dd6scl",
              "policyId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb"
            }
          },
          {
            "quantity": "1",
            "asset": {
              "assetId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb47616d654368616e6765724e4654202333",
              "assetName": "47616d654368616e6765724e4654202333",
              "fingerprint": "asset1yfhkkdwmx80lzkmhf7x677g23v86ej3e86ne8l",
              "policyId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb"
            }
          },
          {
            "quantity": "1",
            "asset": {
              "assetId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb6a6f7267654064726f70636c7562",
              "assetName": "6a6f7267654064726f70636c7562",
              "fingerprint": "asset1tmtmqr9hcvuqaxs6ygqmc5xp0y0yv4j95aa6hr",
              "policyId": "30c804280a94e64767b8f8fd0a2b62c2003d269ff32f0ecfeddf1dfb"
            }
          },
          {
            "quantity": "1000",
            "asset": {
              "assetId": "e51b08690eeab92175848fad8b12a7fe8633c01c21f86808d674747046616b65555344",
              "assetName": "46616b65555344",
              "fingerprint": "asset10t3vswp0h2sz0g4w90tx3xmdj095d92fgrmlh6",
              "policyId": "e51b08690eeab92175848fad8b12a7fe8633c01c21f86808d6747470"
            }
          },
          {
            "quantity": "100",
            "asset": {
              "assetId": "e51b08690eeab92175848fad8b12a7fe8633c01c21f86808d674747047616d654368616e676572546f6b656ef09f9a80",
              "assetName": "47616d654368616e676572546f6b656ef09f9a80",
              "fingerprint": "asset18q2xgm4l07jh4drkue5nmmdl4qwjunsf0m8suw",
              "policyId": "e51b08690eeab92175848fad8b12a7fe8633c01c21f86808d6747470"
            }
          }
        ],
        "value": "2517455"
      }
    ]
  }
}

Environment

CARDANO_GRAPHQL_VERSION=8.3.0

Platform

Platform version

Ubuntu server 20.24

Runtime

Runtime version

No response