Open 0xA1-devops opened 3 weeks ago
@0xA1-devops nice work. Seeing the same thing with Specter Desktop running on umbrelOS.
It looks like Specter has been sending JSON-RPC 2.0 requests for a while: https://github.com/cryptoadvance/specter-desktop/blob/0ac4640a3fcbbb9fd734d01b6eb9cffa5ad9634c/src/cryptoadvance/specter/rpc.py#L399-L404
However, Core is only just now recognizing 2.0 requests as of v28 and sending back 2.0 responses that strictly adhere to the specs: https://www.jsonrpc.org/specification#conventions
Prior to v28, Core would have been responding to Specter's requests with 1.0 responses that always included an error
field, so this issue was never encountered. But in RPC-JSON 2.0, the error
attribute is not included if there was no error:
error
This member is REQUIRED on error.
This member MUST NOT exist if there was no error triggered during invocation.
The value for this member MUST be an Object as defined in section 5.1.
So as @0xA1-devops has shown above, the solution is to handle the case when no error field is present.
In attempting to fix this on my Umbrel (RaspPi4), I had uninstalled Specter and so now cannot reinstall it to try the workaround (removed from app store). When is it likely that a fixed Specter Desktop app for Umbrel will be available in the Umbrel 'Store' for installation?
Unfortunate even the hack fix does not work, when will there be a solution?
https://github.com/cryptoadvance/specter-desktop/issues/2472#issuecomment-2467858958
When using the getblockchaininfo RPC command, a KeyError: 'error' occurs in rpc.py if the server response does not include the error key. Even if there is no error in the response, the code expects this key to be present, which causes a crash when attempting to access it.
Steps to Reproduce:
Environment: Bitcoin Core version: v28.0.0 (release build) Specter from master 0ac4640
Example RPC Response: The following response from a Bitcoin node using curl lacks the error key:
curl --user client:secret --data-binary '{"jsonrpc": "1.0", "id": "curltest", "method": "getblockchaininfo", "params": []}' -H 'content-type: text/plain;' http://127.0.0.1:8332/
Response:As shown, the error key is present but set to null, which can also cause a KeyError if not handled properly.
Error Log:
Temp Solution: In rpc.py, on line 508, replace the line:
if r["error"] is not None:
withif r.get("error") is not None:
This change ensures that if the error key is missing in the response, it defaults to None, preventing the KeyError and allowing the code to handle responses without an error key gracefully.
Proof of Fix: After applying this change, the issue was resolved, and Specter no longer crashes when the error key is missing in the RPC response.