Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sc-6427 Demote protocol errors to warnings #101

Merged
merged 2 commits into from
Jun 29, 2022
Merged

sc-6427 Demote protocol errors to warnings #101

merged 2 commits into from
Jun 29, 2022

Conversation

pdeziel
Copy link
Collaborator

@pdeziel pdeziel commented Jun 28, 2022

This demotes some of the log errors to warnings to avoid spam from the google cloud alerts.

@pdeziel pdeziel requested a review from bbengfort June 28, 2022 14:29
Copy link
Collaborator

@bbengfort bbengfort left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pdeziel looks good to me - my methodology was to look at the error we were returning to the user. If the error was FailedPrecondition then I'm happy with Warn, but if it's Internal, then I think we need to keep it at Error. Thanks for making this change, hopefully this will reduce the amount of messages we get on slack!

@@ -266,14 +266,14 @@ func (s *Server) sendTransfer(req *pb.TransferRequest, account db.Account, parti
// Conduct a GDS lookup if necessary to get the endpoint
var peer *peers.Peer
if peer, err = s.peers.Search(beneficiary.Provider.Name); err != nil {
log.Error().Err(err).Msg("could not search peer from directory service")
log.Warn().Err(err).Msg("could not search peer from directory service")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should remain Error since we're returning codes.Internal here and we may want to look at why the rVASP cannot connect to the directory service.

Copy link
Collaborator Author

@pdeziel pdeziel Jun 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could just be that the given beneficiary VASP doesn't exist in the directory service?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's one possibility (the other is cannot connect) - we should return not found instead of internal if the beneficiary VASP doesn't exist in the directory; Internal otherwise?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that idea, but peers.Search doesn't give us an easy way to distinguish the two currently. Should we just keep it as an internal error for now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, this is Peers from the trisacrypto/trisa repo right? Let's shift to FailedPrecondition instead of internal then (kind of the middle ground between not found and internal) and keep it as warn.

@@ -460,7 +460,7 @@ func (s *Server) sendError(req *pb.TransferRequest, account db.Account) (rep *pb
// Conduct a GDS lookup if necessary to get the endpoint
var peer *peers.Peer
if peer, err = s.peers.Search(beneficiary.Provider.Name); err != nil {
log.Error().Err(err).Msg("could not search peer from directory service")
log.Warn().Err(err).Msg("could not search peer from directory service")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above - I think this should remain an Error since we return codes.Internal.

@@ -503,7 +503,7 @@ func (s *Server) respondAsync(peer *peers.Peer, payload *protocol.Payload, ident

// Verify that the transaction has not expired
if now.Before(xfer.NotBefore) || now.After(xfer.NotAfter) {
log.Error().Err(err).Msg("received expired async transaction")
log.Warn().Err(err).Msg("received expired async transaction")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably just be a Debug -- also, where is err coming from? Is it just nil?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch

Comment on lines +603 to 604
log.Warn().Err(err).Msg("could not find originator account")
return nil, protocol.Errorf(protocol.InternalError, "could not find originator account: %s", err)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though we're returning a protocol.InternalError, we're returning a response so I think this should remain an Warn.

@@ -606,7 +606,7 @@ func (s *TRISA) sendAsync(tx *db.Transaction) (err error) {
if tx.State == pb.TransactionState_PENDING_SENT {
var account *db.Account
if account, err = tx.GetAccount(s.parent.db); err != nil {
log.Error().Err(err).Msg("could not fetch beneficiary account")
log.Warn().Err(err).Msg("could not fetch beneficiary account")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a tough one, if the error is sql.ErrNoRows (e.g. not found) I think it should be a Debug -- if it's a database error, e.g. couldn't connect, schema invalid, etc. it should be an Error. Perhaps you could just put a note with a TODO: check the type of error returned and log appropropriately for the future?

@pdeziel pdeziel merged commit cf90603 into main Jun 29, 2022
@pdeziel pdeziel deleted the sc-6427 branch June 29, 2022 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants