Skip to content

Commit

Permalink
Dealing with bad error response from Hive RPC
Browse files Browse the repository at this point in the history
Adding some logic to stop this response from Hive bringing down the hivewriter.

```
  File "/home/podping/app/.venv/lib/pypy3.8/site-packages/lighthive/client.py", line 167, in validate_response
    raw_body=response,
lighthive.exceptions.RPCNodeException: Internal Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/podping/app/src/podping_hivewriter/podping_hivewriter.py", line 495, in failure_retry
    ex.raw_body["error"]["data"]["name"]
KeyError: 'name'
```
  • Loading branch information
brianoflondon committed Aug 6, 2022
1 parent 0f9759a commit c6d11e1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "podping-hivewriter"
version = "1.2.4"
version = "1.2.5"
license = "MIT"
authors = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
maintainers = ["Alecks Gates <[email protected]>", "Brian of London <[email protected]>"]
Expand Down
28 changes: 18 additions & 10 deletions src/podping_hivewriter/podping_hivewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,25 +491,33 @@ async def failure_retry(
except RPCNodeException as ex:
logging.exception(f"Failed to send {len(iri_set)} IRIs")
try:
# Test if we have a well formed Hive error message
logging.exception(ex)
if (
ex.raw_body["error"]["data"]["name"]
== "tx_missing_posting_auth"
ex.raw_body.get("error")
and ex.raw_body["error"].get("data")
and ex.raw_body["error"]["data"].get("name")
):
if logging.DEBUG >= logging.root.level:
for iri in iri_set:
logging.debug(iri)
logging.error(
f"Terminating: exit code: "
f"{STARTUP_FAILED_INVALID_POSTING_KEY_EXIT_CODE}"
)
sys.exit(STARTUP_FAILED_INVALID_POSTING_KEY_EXIT_CODE)
if (
ex.raw_body["error"]["data"]["name"]
== "tx_missing_posting_auth"
):
if logging.DEBUG >= logging.root.level:
for iri in iri_set:
logging.debug(iri)
logging.error(
f"Terminating: exit code: "
f"{STARTUP_FAILED_INVALID_POSTING_KEY_EXIT_CODE}"
)
sys.exit(STARTUP_FAILED_INVALID_POSTING_KEY_EXIT_CODE)
except Exception:
logging.info(f"Current node: {self.lighthive_client.current_node}")
logging.info(self.lighthive_client.nodes)
logging.exception("Unexpected condition in error text from Hive")
sys.exit(STARTUP_FAILED_UNKNOWN_EXIT_CODE)

except Exception as ex:
logging.exception(ex)
logging.exception(f"Failed to send {len(iri_set)} IRIs")
if logging.DEBUG >= logging.root.level:
for iri in iri_set:
Expand Down

0 comments on commit c6d11e1

Please sign in to comment.