Skip to content

Commit

Permalink
logging cleanups in issue-credential protocols
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Whitehead <[email protected]>
  • Loading branch information
andrewwhitehead committed Feb 8, 2022
1 parent 1422f22 commit 747b88c
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
StorageError,
) as err:
# treat failure to store as mangled on receipt hence protocol error
self._logger.exception(err)
self._logger.exception("Error storing issued credential")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
LedgerError,
StorageError,
) as err:
self._logger.exception(err)
self._logger.exception("Error responding to credential offer")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
LedgerError,
StorageError,
) as err:
self._logger.exception(err)
self._logger.exception("Error responding to credential proposal")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
LedgerError,
StorageError,
) as err:
self._logger.exception(err)
self._logger.exception("Error responding to credential request")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(
Expand Down
4 changes: 3 additions & 1 deletion aries_cloudagent/protocols/issue_credential/v1_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,9 @@ async def send_credential_ack(
await cred_ex_record.delete_record(session) # all done: delete

except StorageError as err:
LOGGER.exception(err) # holder still owes an ack: carry on
LOGGER.exception(
"Error updating credential exchange"
) # holder still owes an ack: carry on

responder = self._profile.inject_or(BaseResponder)
if responder:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ async def save_error_state(
log_override=log_override,
)
except StorageError as err:
LOGGER.exception(err)
LOGGER.exception("Error saving credential exchange error state")

@property
def record_value(self) -> dict:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
V20CredManagerError,
) as err:
# treat failure to store as mangled on receipt hence protocol error
self._logger.exception(err)
self._logger.exception("Error storing issued credential")
if cred_ex_record:
async with context.profile.session() as session:
await cred_ex_record.save_error_state(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
StorageError,
V20CredManagerError,
) as err:
self._logger.exception(err)
self._logger.exception("Error responding to credential offer")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder):
StorageError,
V20CredManagerError,
) as err:
self._logger.exception(err)
self._logger.exception("Error responding to credential proposal")
async with profile.session() as session:
await cred_ex_record.save_error_state(
session,
Expand Down
8 changes: 5 additions & 3 deletions aries_cloudagent/protocols/issue_credential/v2_0/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,13 @@ async def send_cred_ack(
# FIXME - re-fetch record to check state, apply transactional update
await cred_ex_record.save(session, reason="store credential v2.0")

if cred_ex_record.auto_remove:
await cred_ex_record.delete_record(session) # all done: delete
if cred_ex_record.auto_remove:
await self.delete_cred_ex_record(cred_ex_record.cred_ex_id)

except StorageError as err:
LOGGER.exception(err) # holder still owes an ack: carry on
LOGGER.exception(
"Error sending credential ack"
) # holder still owes an ack: carry on

responder = self._profile.inject_or(BaseResponder)
if responder:
Expand Down
15 changes: 14 additions & 1 deletion aries_cloudagent/protocols/issue_credential/v2_0/routes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Credential exchange admin routes."""

from ....vc.ld_proofs.error import LinkedDataProofException
import logging

from json.decoder import JSONDecodeError
from typing import Mapping

Expand Down Expand Up @@ -33,6 +34,7 @@
)
from ....storage.error import StorageError, StorageNotFoundError
from ....utils.tracing import trace_event, get_timer, AdminAPIMessageTracingSchema
from ....vc.ld_proofs.error import LinkedDataProofException

from . import problem_report_for_record, report_problem
from .manager import V20CredManager, V20CredManagerError
Expand All @@ -47,6 +49,8 @@
from .formats.handler import V20CredFormatError
from .formats.ld_proof.models.cred_detail import LDProofVCDetailSchema

LOGGER = logging.getLogger(__name__)


class V20IssueCredentialModuleResponseSchema(OpenAPISchema):
"""Response schema for v2.0 Issue Credential Module."""
Expand Down Expand Up @@ -658,6 +662,7 @@ async def credential_exchange_send(request: web.BaseRequest):
V20CredManagerError,
V20CredFormatError,
) as err:
LOGGER.exception("Error preparing credential offer")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -746,6 +751,7 @@ async def credential_exchange_send_proposal(request: web.BaseRequest):
result = cred_ex_record.serialize()

except (BaseModelError, StorageError) as err:
LOGGER.exception("Error preparing credential proposal")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -866,6 +872,7 @@ async def credential_exchange_create_free_offer(request: web.BaseRequest):
V20CredFormatError,
V20CredManagerError,
) as err:
LOGGER.exception("Error creating free credential offer")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -947,6 +954,7 @@ async def credential_exchange_send_free_offer(request: web.BaseRequest):
V20CredFormatError,
V20CredManagerError,
) as err:
LOGGER.exception("Error preparing free credential offer")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -1051,6 +1059,7 @@ async def credential_exchange_send_bound_offer(request: web.BaseRequest):
V20CredFormatError,
V20CredManagerError,
) as err:
LOGGER.exception("Error preparing bound credential offer")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -1155,6 +1164,7 @@ async def credential_exchange_send_free_request(request: web.BaseRequest):
StorageError,
V20CredManagerError,
) as err:
LOGGER.exception("Error preparing free credential request")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -1244,6 +1254,7 @@ async def credential_exchange_send_bound_request(request: web.BaseRequest):
V20CredFormatError,
V20CredManagerError,
) as err:
LOGGER.exception("Error preparing bound credential request")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -1329,6 +1340,7 @@ async def credential_exchange_issue(request: web.BaseRequest):
V20CredFormatError,
V20CredManagerError,
) as err:
LOGGER.exception("Error preparing issued credential")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down Expand Up @@ -1408,6 +1420,7 @@ async def credential_exchange_store(request: web.BaseRequest):
StorageError,
V20CredManagerError,
) as err: # treat failure to store as mangled on receipt hence protocol error
LOGGER.exception("Error storing issued credential")
if cred_ex_record:
async with profile.session() as session:
await cred_ex_record.save_error_state(session, reason=err.roll_up)
Expand Down

0 comments on commit 747b88c

Please sign in to comment.