cardano-foundation / cardano-graphql

GraphQL API for Cardano
Apache License 2.0
255 stars 103 forks source link

INTERNAL_SERVER_ERROR: TypeError: Cannot read properties of null (reading 'assetId') #877

Open cryptosystems6300 opened 2 weeks ago

cryptosystems6300 commented 2 weeks ago

Summary

Graphql query returns an unexpected internal server error

Steps to reproduce the bug

  1. send graphql query
    query {
    paymentAddresses(
    addresses: [
      "addr1qygcsk5l4xh3y3m8j8akv93yyun06wfadrr3de02vj80xyg33pdfl2d0zfrk0y0mvctzgfexl5un66x8zmj75eyw7vgsfpl75e"
    ]
    ) {
    summary {
      assetBalances {
        asset {
          assetId
        }
        quantity
      }
    }
    }
    }

Actual Result

{
  "errors": [
    {
      "message": "TypeError: Cannot read properties of null (reading 'assetId')",
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "path": [
        "paymentAddresses",
        0,
        "summary"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: TypeError: Cannot read properties of null (reading 'assetId')",
            "    at /app/packages/api-cardano-db-hasura/dist/executableSchema.js:93:39",
            "    at Generator.throw (<anonymous>)",
            "    at rejected (/app/packages/api-cardano-db-hasura/dist/executableSchema.js:6:65)",
            "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
          ]
        }
      }
    }
  ],
  "data": {
    "paymentAddresses": [
      {
        "summary": null
      }
    ]
  }
}

Expected Result

actual balances

Environment

mainnet

Platform

Platform version

No response

Runtime

Runtime version

No response

itsmehdiabdi commented 2 weeks ago

Summary

Graphql query returns an unexpected internal server error

Steps to reproduce the bug

  1. send graphql query
query {
  paymentAddresses(
    addresses: [
      "addr1qygcsk5l4xh3y3m8j8akv93yyun06wfadrr3de02vj80xyg33pdfl2d0zfrk0y0mvctzgfexl5un66x8zmj75eyw7vgsfpl75e"
    ]
  ) {
    summary {
      assetBalances {
        asset {
          assetId
        }
        quantity
      }
    }
  }
}

Actual Result

{
  "errors": [
    {
      "message": "TypeError: Cannot read properties of null (reading 'assetId')",
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "path": [
        "paymentAddresses",
        0,
        "summary"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR",
        "exception": {
          "stacktrace": [
            "Error: TypeError: Cannot read properties of null (reading 'assetId')",
            "    at /app/packages/api-cardano-db-hasura/dist/executableSchema.js:93:39",
            "    at Generator.throw (<anonymous>)",
            "    at rejected (/app/packages/api-cardano-db-hasura/dist/executableSchema.js:6:65)",
            "    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)"
          ]
        }
      }
    }
  ],
  "data": {
    "paymentAddresses": [
      {
        "summary": null
      }
    ]
  }
}

Expected Result

actual balances

Environment

mainnet

Platform

  • [ ] Linux (Ubuntu)
  • [ ] Linux (Other)
  • [ ] macOS
  • [ ] Windows

Platform version

No response

Runtime

  • [ ] Node.js
  • [ ] Docker

Runtime version

No response

i'm facing the same issue. i get this error when i run the same query with an account that has many different tokens. the account you mentioned has 50 different tokens! in my case i just need ada balance. but i don't know how to filter it and just get ada balance. i think it would solve my own problem. @cryptosystems6300

itsmehdiabdi commented 2 weeks ago

in my case this helped me: ` query = """ query PaymentAddressSummary ($address: String!){ utxos ( where: { _and: {
address: { _eq: $address } } } ) { value } }

"""

graphql_url = "https://explorer.cardano.org/graphql/" address = "addr1vqkzkjxm33tms7xr5qjuu92m3ygs8mpfvvyncp3atj08hlgh9n7xs" data = {"query": query, "variables": {"address": address}} response = requests.post( url=graphql_url, headers={"Content-Type": "application/json"}, data=json.dumps(data), timeout=60, )

utxos = response.json().get("data").get("utxos") balance = sum([utxo['value'] for utxo in utxos]) print(balance) `