error.response.data.error.id does not exist
Preflight checklist
- [X] I could not find a solution in the existing issues, docs, nor discussions.
- [X] I agree to follow this project's Code of Conduct.
- [X] 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
I'm using Ory Network and have encountered an issue with error handling in the example code.
The condition in this file: https://github.com/ory/elements/blob/cbf29d818bb38fab3d66dcaf53d7d70bcdbbea51/examples/react-spa/src/sdk.ts#L42
suggests that error.response.data.error.id might exist. Similar conditions appear multiple times in the same file.
However, in practice, error.response.data.error does not exist. It's unclear whether this is an issue with Ory Network or if the condition itself is incorrect.
When cloning this repository and testing it with an Ory Network project, I observed that:
error.response.data.errordoes not exist.- In the case of "session_already_available", it's expected to redirect to the root, but instead, an error message is displayed: "A valid session was detected and thus login is not possible. Did you forget to set
?refresh=true?"
How should we correctly handle different error scenarios based on the error ID?
Could you please clarify:
- The correct structure of the error object returned by Ory Network.
- The proper way to handle different error types, especially the "session_already_available" case.
Reproducing the bug
- Launch the react-spa example from this repository.
- Use an Ory Network project for authentication.
- Open the login screen in two separate browser tabs.
- Log in successfully on one tab.
- Attempt to log in on the second tab.
Expected Behavior: The user should be redirected to the "Welcome to the dashboard!" page on the second tab.
Actual Behavior: An error message "A valid session was detected and thus login is not possible. Did you forget to
Relevant log output
No response
Relevant configuration
No response
Version
Ory Network
On which operating system are you observing this issue?
None
In which environment are you deploying?
None
Additional Context
No response