Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"unexpected type float64 for Long" error when run graphql with parameters of type Long #24683

Closed
ngugcx opened this issue Apr 12, 2022 · 4 comments · Fixed by #24864
Closed
Assignees
Labels

Comments

@ngugcx
Copy link

ngugcx commented Apr 12, 2022

System information

Geth version: geth version

/ # geth version
Geth
Version: 1.10.17-stable
Git Commit: 25c9b49fdb74931137431c24cf28d3c65f9420d2
Architecture: amd64
Go Version: go1.18
Operating System: linux

OS & Version: Windows/Linux/OSX

/ # uname -a
Linux 69c4dda6023d 5.4.0-81-generic #91-Ubuntu SMP Thu Jul 15 19:09:17 UTC 2021 x86_64 Linux

Commit hash : (if develop)

Expected behaviour

curl 'http://localhost:8545/graphql' --data-raw $'{"query":"query blocks($from_: Long!, $to_: Long!) {  blocks(from: $from_, to: $to_) {    number    hash    timestamp  }}","variables":{"from_":14000000,"to_":14000001},"operationName":"blocks"}'

It should return the specified block info.

Actual behaviour

It returns:

{"errors":[{"message":"unexpected type float64 for Long"}],"data":{}}

Steps to reproduce the behaviour

Run geth as below:

geth --txlookuplimit=1000000 --http --http.addr=0.0.0.0 --http.api eth,net,web3 --http.corsdomain="*" --http.vhosts="*" --graphql --graphql.corsdomain="*" --graphql.vhosts="*" --ws --ws.addr=0.0.0.0 --ws.api eth,net,web3

Backtrace

[backtrace]

When submitting logs: please submit them as text and not screenshots.

@Kantitad
Copy link

Kantitad commented Apr 12, 2022 via email

@s1na
Copy link
Contributor

s1na commented Apr 12, 2022

Try sending the values as strings, i.e.:

"variables":{"from_":"14000000","to_":"14000001"}

@ngugcx
Copy link
Author

ngugcx commented Apr 12, 2022

Try sending the values as strings, i.e.:

"variables":{"from_":"14000000","to_":"14000001"}

Yes, strings work.
Why integers are always parsed as float? JSON has integer type.

@s1na
Copy link
Contributor

s1na commented Apr 13, 2022

So interestingly this only happens when using variables. Embedding the value in the query itself works fine, e.g. query block(num: 14000000) { hash } works ok.

Edit: created an issue upstream graph-gophers/graphql-go#514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants