elements icon indicating copy to clipboard operation
elements copied to clipboard

error.response.data.error.id does not exist

Open ysds opened this issue 1 year ago • 0 comments

Preflight checklist

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.

image

When cloning this repository and testing it with an Ory Network project, I observed that:

  1. error.response.data.error does not exist.
  2. 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?"
image

How should we correctly handle different error scenarios based on the error ID?

Could you please clarify:

  1. The correct structure of the error object returned by Ory Network.
  2. The proper way to handle different error types, especially the "session_already_available" case.

Reproducing the bug

  1. Launch the react-spa example from this repository.
  2. Use an Ory Network project for authentication.
  3. Open the login screen in two separate browser tabs.
  4. Log in successfully on one tab.
  5. 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

ysds avatar Oct 23 '24 03:10 ysds