Skip to content

Commit

Permalink
refactor: move some qnf error bodies and TEL success body to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
kentbull committed Dec 26, 2024
1 parent 1550ac1 commit 2b7e0ca
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
24 changes: 15 additions & 9 deletions src/keri/core/eventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2714,8 +2714,8 @@ def logEvent(self, serder, sigers=None, wigers=None, wits=None, first=False,
fn, serder.pre, dtsb.decode())
logger.debug("Event Body=\n%s\n", serder.pretty())
self.db.addKe(snKey(serder.preb, serder.sn), serder.saidb)
logger.info("Kever: Added to KEL valid event: %s for AID %s", serder.said, serder.pre)
logger.debug("Event Body=\n%s\n", serder.pretty())
logger.info("Kever: Added to KEL valid %s event %s for AID %s", serder.ilk, serder.said, serder.pre)
logger.debug("KEL Event Body=\n%s\n", serder.pretty())
return (fn, dtsb.decode("utf-8")) # (fn int, dts str) if first else (None, dts str)

def escrowPSEvent(self, serder, sigers, wigers=None):
Expand Down Expand Up @@ -4125,18 +4125,20 @@ def processQuery(self, serder, source=None, sigers=None, cigars=None):
if pre not in self.kevers:
self.escrowQueryNotFoundEvent(serder=serder, prefixer=source, sigers=sigers, cigars=cigars)
logger.debug("Query not found error. Query Body=%s", ked)
raise QueryNotFoundError(f"Query not found error for evt {ked['d']} at route {ked['r']}")
raise QueryNotFoundError(f"Query not found error for at route {ked['r']} for evt {ked['d']}")

kever = self.kevers[pre]
if anchor:
if not self.db.findAnchoringSealEvent(pre=pre, seal=anchor):
self.escrowQueryNotFoundEvent(serder=serder, prefixer=source, sigers=sigers, cigars=cigars)
raise QueryNotFoundError("Query not found error={}.".format(ked))
logger.debug("Query not found error. Query Body=%s", ked)
raise QueryNotFoundError(f"Query not found error at route {ked['r']} for evt {ked['d']}")

elif sn is not None:
if kever.sner.num < sn or not self.db.fullyWitnessed(kever.serder):
self.escrowQueryNotFoundEvent(serder=serder, prefixer=source, sigers=sigers, cigars=cigars)
raise QueryNotFoundError("Query not found error={}.".format(ked))
logger.debug("Query not found error. Query Body=%s", ked)
raise QueryNotFoundError(f"Query not found error at route {ked['r']} for evt {ked['d']}")

msgs = list() # outgoing messages
for msg in self.db.clonePreIter(pre=pre, fn=0):
Expand All @@ -4156,7 +4158,8 @@ def processQuery(self, serder, source=None, sigers=None, cigars=None):

if pre not in self.kevers:
self.escrowQueryNotFoundEvent(serder=serder, prefixer=source, sigers=sigers, cigars=cigars)
raise QueryNotFoundError("Query not found error={}.".format(ked))
logger.debug("Query not found error. Query Body=%s", ked)
raise QueryNotFoundError(f"Query not found error at route {ked['r']} for evt {ked['d']}")

kever = self.kevers[pre]

Expand All @@ -4166,7 +4169,8 @@ def processQuery(self, serder, source=None, sigers=None, cigars=None):

if len(wigers) < kever.toader.num:
self.escrowQueryNotFoundEvent(serder=serder, prefixer=source, sigers=sigers, cigars=cigars)
raise QueryNotFoundError("Query not found error={}.".format(ked))
logger.debug("Query not found error. Query Body=%s", ked)
raise QueryNotFoundError(f"Query not found error at route {ked['r']} for evt {ked['d']}")

rserder = reply(route=f"/ksn/{src}", data=kever.state()._asdict())
self.cues.push(dict(kin="reply", src=src, route="/ksn", serder=rserder,
Expand All @@ -4179,7 +4183,8 @@ def processQuery(self, serder, source=None, sigers=None, cigars=None):

if pre not in self.kevers:
self.escrowQueryNotFoundEvent(serder=serder, prefixer=source, sigers=sigers, cigars=cigars)
raise QueryNotFoundError("Query not found error={}.".format(ked))
logger.debug("Query not found error. Query Body=%s", ked)
raise QueryNotFoundError(f"Query not found error at route {ked['r']} for evt {ked['d']}")

self.cues.push(dict(kin="stream", serder=serder, pre=pre, src=src, topics=topics))
# if pre in self.kevers:
Expand All @@ -4188,7 +4193,8 @@ def processQuery(self, serder, source=None, sigers=None, cigars=None):
# self.cues.push(dict(kin="stream", serder=serder, pre=pre, src=src, topics=topics))
else:
self.cues.push(dict(kin="invalid", serder=serder))
raise ValidationError("invalid query message {} for evt = {}".format(ilk, ked))
logger.debug("Invalid Query error. Query Body=%s", ked)
raise ValidationError(f"invalid query message {ilk} at route {ked['r']} for evt = {ked['d']}")

def fetchEstEvent(self, pre, sn):
"""
Expand Down
6 changes: 6 additions & 0 deletions src/keri/core/parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,12 @@ def msgParsator(self, ims=None, framed=True, pipeline=False,
except AttributeError:
raise kering.ValidationError("No kevery to process so dropped msg"
"= {}.".format(serder.pretty()))
except kering.QueryNotFoundError as e: # catch escrow error and log it
if logger.isEnabledFor(logging.TRACE):
logger.exception("Error processing query = %s", e)
logger.trace("Query Body=\n%s\n", serder.pretty())
else:
logger.error("Error processing query = %s", e)

elif route in ["tels", "tsn"]:
try:
Expand Down
4 changes: 2 additions & 2 deletions src/keri/vdr/eventing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1267,8 +1267,8 @@ def logEvent(self, pre, sn, serder, seqner, saider, bigers=None, baks=None):
self.reger.tets.pin(keys=(pre.decode("utf-8"), dig.decode("utf-8")), val=coring.Dater())
self.reger.putTvt(key, serder.raw)
self.reger.putTel(snKey(pre, sn), dig)
logger.info("Tever state: %s Added to TEL valid event=\n%s\n",
pre, serder.pretty())
logger.info("Tever: Added to TEL valid %s event=%s for AID %s", serder.ilk, serder.said, pre)
logger.debug("TEL Event Body=\n%s\n", serder.pretty())

def valAnchorBigs(self, serder, seqner, saider, bigers, toad, baks):
""" Validate anchor and backer signatures (bigers) when provided.
Expand Down

0 comments on commit 2b7e0ca

Please sign in to comment.