When the database cannot be connected, /oauth2/token returns a 401 status code instead of 500
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 17.6k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
Preflight checklist
- I could not find a solution in the existing issues, docs, nor discussions.
- I agree to follow this project's Code of Conduct.
- I have read and am following this repository's Contribution Guidelines.
- I have joined the Ory Community Slack.
- I am signed up to the Ory Security Patch Newsletter.
Ory Network Project
No response
Describe the bug
When the database cannot be connected, /oauth2/token returns a 401 status code instead of 500
Reproducing the bug
1、Create a OAuht2 Client with Client Credentail Mode
2、Restart the database and immediately request an access token
3、Then you can reproduce the bug
Relevant log output
No response
Relevant configuration
No response
Version
v2.1.2
On which operating system are you observing this issue?
Linux
In which environment are you deploying?
Kubernetes with Helm
Additional Context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the /oauth2/token endpoint and reproduce the sequence by restarting the database before requesting a client-credentials token. Trace how the database connection failure is converted into the HTTP response, then verify the endpoint returns 500 rather than 401 when the database is unavailable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, helm, kubernetes
- Domain
- api, authentication, databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100