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

feat: add bulk error handling notification callbacks #911

Merged
merged 19 commits into from
Aug 1, 2022

Conversation

kleyow
Copy link
Contributor

@kleyow kleyow commented Jul 22, 2022

image

  • Add duplicate request handling for bulk transfer request
  • Add error notification handling for failed bulk transfer/failed validation/unexpected db errors.
  • Improve participant validation for bulk transfers

@kleyow kleyow marked this pull request as ready for review July 28, 2022 21:47
@kleyow kleyow changed the title feat: add bulk error handling feat: add bulk error handling notification callbacks Jul 28, 2022
if (hasDuplicateId && hasDuplicateHash) {
Logger.isErrorEnabled && Logger.error(Util.breadcrumb(location, `callbackErrorModified--${actionLetter}1`))

const fspiopError = ErrorHandler.Factory.createFSPIOPError(ErrorHandler.Enums.FSPIOPErrorCodes.MODIFIED_REQUEST, 'Bulk transfer prepare duplicate')
Copy link
Member

@elnyry-sam-k elnyry-sam-k Aug 1, 2022

Choose a reason for hiding this comment

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

The behavior on duplicate requests is that:

  • If the ID (here bulkTransferID) and the message hash matches, it is essentially a "resend", so in this case - "IF the bulkTransfer is in a final state (final states for bulk - COMPLETED, REJECTED), we treat it as a GET /bulkTransfers/{ID} call and send out a PUT /bulkTransfers/{ID} with the same payload as that of a final notification. If however, the bulkTransfer is in a non-final state (the rest in the BulkTransferState enum - RECEIVED, PENDING, ACCEPTED, PROCESSING), then we do not send anything back, allowing the final notification to be sent once processing is done."
  • On a bulkTransfer if a previously used ID is used but the message is different or modified (hash is different), then we send out the error callback saying its a "modified request"

Here's the section in the FSPIOP API spec discussing this behavior: https://docs.mojaloop.io/api/fspiop/v1.1/api-definition.html#duplicate-analysis-in-server-on-receiving-a-http-post-request

// Check to see if the resend is coming from a participant of involved
// with the bulk transfer to avoid potential data leakage.
const participants = await BulkTransferService.getParticipantsById(bulkTransferId)
if (![participants.payeeFsp, participants.payerFsp].includes(message.value.from)) {
Copy link
Member

Choose a reason for hiding this comment

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

This one and the next check should be unreachable code, isn't it? "hasDuplicateHash" should indicate that the headers and payload are exactly same as before.. So the check that this is coming from the same Payer FSP as before should already be covered there..

params.message.value.content.uriParams = { id: bulkTransferId }
// Resend should typically only occur by the Payer FSP, but lets
// handle if the same request is somehow sent by the Payer FSP.
const isPayeeRequest = participants.payeeFsp === message.value.from
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't be needed, isn't it? (handled by "hasDuplicateHash")

@kleyow kleyow merged commit 9ac6e1a into mojaloop:master Aug 1, 2022
@kleyow kleyow deleted the feat/bulk-error-handling branch August 1, 2022 18:47
@kleyow
Copy link
Contributor Author

kleyow commented Oct 20, 2022

mojaloop/project#2798

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants