Skip to content

fix(mojaloop/#3838): return 409 with proper errorInformation for duplicate participant registration - #294

Open
kaydendua wants to merge 10 commits into
mojaloop:mainfrom
kaydendua:fix/3838
Open

fix(mojaloop/#3838): return 409 with proper errorInformation for duplicate participant registration#294
kaydendua wants to merge 10 commits into
mojaloop:mainfrom
kaydendua:fix/3838

Conversation

@kaydendua

Copy link
Copy Markdown

POST /oracle/participants/{Type}/{ID} throws a bare Error when the ID already exists, which falls through to a generic error response: 500, errorCode 2001, Internal server error. This PR replaces the throw with an explicit 409 response with errorCode 3003 (ADD_PARTY_INFO_ERROR) with an errorDescription.

Note:
It seems like there might be similar issues in the same file that are outside of the scope of this issue:

  1. createParticipantsBatch uses error code "1234" instead of "3003" for its participant already exists error.
  2. The same "throw new Error(...)" code is used for updateParticipantsByTypeId and delParticipantsByTypeId, which will cause the same issue of falling through to a generic 500 error response.

Fixes mojaloop/project#3838

…icipant registration

POST /oracle/participants/{Type}/{ID} throws a bare Error when the ID already exists, which falls through to a generic error response: 500, errorCode 2001, Internal server error. Now it returns 409 with errorCode 3003 (ADD_PARTY_INFO_ERROR) with an errorDescription
@CLAassistant

CLAassistant commented Aug 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread src/oracle/handler.js
Comment thread src/oracle/handler.js
throw new Error(`ID:${request.params.ID} already exists`)
const errorObject = {
errorCode: 3003,
errorDescription: `Party already exists: ID:${request.params.ID}`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lets have a consistent error description for both (ideally all but at least the ones we're touching here)

@elnyry-sam-k

Copy link
Copy Markdown
Member

also, can we have some unit tests, at least for the newly added code? thanks

@kaydendua

Copy link
Copy Markdown
Author

Note: dep:check failed due to outdated dependencies unrelated to this PR. Used -n to commit.

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.

ALS - Error description is wrong in PUT /participants error callback

3 participants