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

a few 500 Internal Server Errors (SQLITE_CONSTRAINT_PRIMARYKEY) #592

Closed
pohutukawa opened this issue Jul 9, 2024 · 0 comments · Fixed by #597
Closed

a few 500 Internal Server Errors (SQLITE_CONSTRAINT_PRIMARYKEY) #592

pohutukawa opened this issue Jul 9, 2024 · 0 comments · Fixed by #597
Assignees
Labels
bug Something isn't working

Comments

@pohutukawa
Copy link

Describe the bug
Exploring the wallet-api, I have stumbled upon a few unhandled exceptions leading to 500 Internal Server Errors. In this case they were all tied to primary key constraint errors in the DB, so I would guess that they're likely applicable to other persistence back-ends as well.

Specifically they have occurred in the following cases:

  • Create an account if the account ID (email) already exists. ({"exception":true,"status":"Internal Server Error","code":"500","message":"Could not register user: Account already exists!"})
  • Create a DID (Web) if the DID already exists. ({"exception": true, "status": "Internal Server Error", "code": "500", "message": "org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_PRIMARYKEY] A PRIMARY KEY constraint failed (UNIQUE constraint failed: wallet_dids.wallet, wallet_dids.did)"})
  • Import a key (JWK) if the key ID (auto-generated) already exists. ({"exception":true,"status":"Internal Server Error","code":"500","message":"org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_PRIMARYKEY] A PRIMARY KEY constraint failed (UNIQUE constraint failed: wallet_keys.wallet, wallet_keys.kid)"})

To Reproduce
Steps to reproduce the behaviour:

  1. Import a key in JWK format: POST /wallet-api/wallet/{wallet}/keys/import
  2. Import that same key in JWK format again.
  3. Observe the API returning a 500 error due to an unhandled exception.

Expected behaviour
A 409 Conflict or 400 Bad Request error response after successfully handling the exception.

Actual behaviour
An unhandled exception/not gracefully handled exception leading to a 500 Internal Server Error response without significant meaningful context assisting the user to resolve the situation.
eenshots to help explain your problem.

Environment
Desktop (please complete the following information):

  • Browser: curl command line or other scripted (e.g. via Python requests)
    Additional context
    Add any other context about the problem here.
@pohutukawa pohutukawa added the bug Something isn't working label Jul 9, 2024
@SuperBatata SuperBatata self-assigned this Jul 9, 2024
@SuperBatata SuperBatata linked a pull request Jul 9, 2024 that will close this issue
15 tasks
@SuperBatata SuperBatata mentioned this issue Jul 9, 2024
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants