openwallet-foundation / acapy-endorser-service

endorser-service
https://wiki.hyperledger.org/display/aries
Apache License 2.0
6 stars 11 forks source link

500 error with query returned from trying to add duplicate DID allowance #44

Closed loneil closed 6 months ago

loneil commented 10 months ago

In the POST allow/publish-did/{DID} endpoint if a duplicate DID allowance is attempted a 500 error in the following form returns

{
  "detail": "(sqlalchemy.dialects.postgresql.asyncpg.IntegrityError) <class 'asyncpg.exceptions.UniqueViolationError'>: duplicate key value violates unique constraint \"allowedpublicdid_pkey\"\nDETAIL:  Key (registered_did)=(123) already exists.\n[SQL: INSERT INTO allowedpublicdid (registered_did) VALUES (%s) RETURNING allowedpublicdid.created_at, allowedpublicdid.updated_at]\n[parameters: ('123',)]\n(Background on this error at: https://sqlalche.me/e/14/gkpj)"
}

Would handle this with a cleaner 4xx level error I think.

Gavinok commented 9 months ago

Does 409 make more sense in this case?

loneil commented 9 months ago

Yeah either 409 conflict, or 422 invalid data would make sense to me.