Not correctly reporting nonce errors
See original GitHub issueI noticed this today when doing a doc update for pythonanywhere. I used an old API key and was getting
HTTP Error 422: Requesting returnOpenLoanOffers
After messing about with pdb I found it was actually
(Pdb) ex.read()
'{"error":"Nonce must be greater than 149457735191782915. You provided 1494578980835."}'
So these aren’t showing the full issue:
(Pdb) ex
HTTPError()
(Pdb) str(ex)
'HTTP Error 422: '
(Pdb) ex.message
'HTTP Error 422: Requesting returnOpenLoanOffers'
I’ll have a closer look, but I think we might need to do a bit more handling on exceptions when we catch them.
It’s pretty easy to replicate, just set your req['nonce'] = int(time.time() * 1000)
to req['nonce'] = int(time.time() * 10)
or something.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
What a Nonce Error Is & How to Fix It - HubSpot Blog
A nonce error is caused when a user makes a request without having the correct nonce generated by WordPress and given to the...
Read more >Nonce error at checkout with Easy Digital Downloads
Hello, I'm running into an issue that I cannot seem to properly resolve. I have the plugin Easy Digital Downloads installed, and when...
Read more >UsingWW: The "duplicate nonce" error is back - WeBWorK
I click on a problem, answer one of the questions, click grade, and the grade is reported to be successfully sent back to...
Read more >Avoid reporting "Invalid Nonce" when removing a transaction if ...
I'm deploying and executing a series of transaction to a contract on a fresh chain, and it all works well except there are...
Read more >Server: Nonce not found error when modifying schedules
Solved: Hi all I hope someone might be able to help with this, we have recently upgraded our server version to 2020.2 and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
… making a PR now.
@rnevet - It’s only handled there if the response is HTTP 200. The issue is if the response has an error code it’s returned as a
urllib2.HTTPError
. However, according to the docs, that exception can be handled in the same way as the return value fromurlopen
so you can read the body contents (if any). I put it in a try-except block because it’s possible to get an HTTP error code with no usable body.As laxdog said, you can just change the nonce calculation to force it to return an error and you get back the message I quoted above.
The API docs are pretty lacking because it doesn’t state anywhere when you get HTTP error codes and when you don’t.