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

JS Client session identity is generated as optional even though it's marked as required in the spec #293

Open
4 of 5 tasks
dnlsndr opened this issue Sep 23, 2023 · 0 comments
Labels
bug Something is not working.

Comments

@dnlsndr
Copy link

dnlsndr commented Sep 23, 2023

Preflight checklist

Ory Network Project

No response

Describe the bug

As far as I understood, every session always has a identity in it's response.
This is also the case in the openapi spec under the session, where identity and id are set to be required fields.
But apparently the javascript/typescript client does not generate it as such, and generates it as a optional field in the Session type. This causes issues in our project down the road, because we would either have to do unnecessary checks all over the place just to satisfy TypeScript in that reagard, or overwrite your internal Session type such that the identity is not optional.

Reproducing the bug

Create a typescript project,

  1. Call toSession({...}) on a FrontendApi client instance.
  2. Try accessing the session.identity.id attribute, which fails
  3. Note that typescript is telling you that the "identity might be undefined"

Relevant log output

'session.identity' is possibly 'undefined'.ts(18048)
(property) Session['identity']?: Identity | undefined

@type — {Identity}
@memberof — Session

Relevant configuration

No response

Version

Kratos 1.0.0 and the latest npm client

On which operating system are you observing this issue?

Linux

In which environment are you deploying?

Docker

Additional Context

No response

@dnlsndr dnlsndr added the bug Something is not working. label Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working.
Projects
None yet
Development

No branches or pull requests

1 participant