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
Cannot read properties of null (reading '__helper') #4688
Comments
Can you please provide minimal reproduction? So a script, no additional dependencies, no web servers, no GQL... |
Hello @B4nan! Update, I have found out who causes it: Apparently when I do this query in the guard using the token entity, that's when the error appears, if I don't do that query, everything works fine. https://github.com/kent-0/api/blob/main/src/modules/auth/strategy/jwt.strategy.ts#L96-L122 Knowing that, I will try to replicate the error. Update 2: I have not been able to replicate it again in another project. :( |
Problem solved. The problem came from this query: const tokenSession = await this.tokensRepository.findOne({
revoked: false,
token_type: TokenType.AUTH,
token_value: token,
user: payload.sub,
}); That it was being used in an authentication guard: https://github.com/kent-0/api/blob/4865ad815431d8d5770bbd2ad39fe0c9db72675e/src/modules/auth/strategy/jwt.strategy.ts#L96-L101 Then changing it to: const tokenSession = await this.em.fork().findOne(AuthTokensEntity, {
revoked: false,
token_type: TokenType.AUTH,
token_value: token,
user: payload.sub,
}); It has worked correctly now. |
So it's about contexts, you apparently have something loaded to the context that affects the following query and hydration. Btw I see you have |
Looks more to me like a code issue rather than an orm issue. Since its solved , i think it can be closed |
Well, it's not solved, he just worked it around by using a clear context. Even if it would be a context issue, this is an error that shouldn't happen, it's not some validation but a I guess I will just add a check to that specific line where it throws... |
Describe the bug
I have a users entity that references several entities, so what I try to do is to use the fields property of the query to limit which fields to show from the nested properties, but then when I try to limit the properties of the owner field of the projectmembers entity from the project entity then I get the error
Cannot read properties of null (reading '__helper')
.My project is open source, and you can see who is causing the error here:
https://github.com/kent-0/api/blob/main/src/modules/auth/services/account.service.ts#L126-L174
If you need to run the project, there is an (https://github.com/kent-0/api/blob/main/.env.example) file that you just need to rename to
.env
and set its values.Stack trace
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Result of the relationship of the property owner of the entity project members of the entity project resolved correctly with the fields that were set to view.
Additional context
I am using mikro-orm with nestjs and I am using postgres as database.
Versions
The text was updated successfully, but these errors were encountered: