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
fix(core): improve validation of wrong entity references #3085
Conversation
…ined" from obscuring the fromWrongReference MetadataError
Codecov Report
@@ Coverage Diff @@
## master #3085 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 193 193
Lines 11881 11881
Branches 2742 2742
=========================================
Hits 11881 11881
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's simplify and more importantly, add a test case - this is coming from wrong decorator usage, right? so can be just a unit test in https://github.com/mikro-orm/mikro-orm/blob/master/tests/decorators.test.ts
Co-authored-by: Martin Adámek <banan23@gmail.com>
@B4nan I made your suggested change. I'm going to hold off on writing a test for this until I can fix my own bug.
I'm still running into the underlying error. So I do not know where this is coming from. Which is a part of the reason why I'm not in a position to write a test. My best guess thus far is some production-only circular dependency issue. Idk 🤷 |
Dropping this in hopes this could possibly reproduce the issue later: import { Field, ObjectType } from '@nestjs/graphql';
import {
Collection,
Entity,
IdentifiedReference,
ManyToOne,
OneToMany,
} from '@mikro-orm/core';
import { MyBaseEntity } from '@my/entities';
@ObjectType()
@Entity()
export class OpsManagerService extends MyBaseEntity<OpsManagerService> {
@OneToMany({
entity: () => OpsManagerEnvironmentService,
mappedBy: 'opsManagerService',
})
public opsManagerEnvironmentServices = new Collection<OpsManagerEnvironmentService>(
this
);
}
@ObjectType()
@Entity()
export class OpsManagerEnvironmentService extends MyBaseEntity<OpsManagerEnvironmentService> {
@ManyToOne({
entity: () => OpsManagerService,
eager: true,
wrappedReference: true,
inversedBy: 'opsManagerEnvironmentServices',
})
@Field(() => OpsManagerService, { nullable: false })
opsManagerService: IdentifiedReference<OpsManagerService>;
} |
Hmmm.... seems that Mikro is logging some inconsistencies between two class references. I'm console logging out everything that comes into the validate bidirectional functions, and I'm seeing two different path types: One entity's path is the bundle: The other's path is a webpack path: |
I was asking for a unit test case, not sure what that (very incomplete) entity definition should reproduce... Also hearing about webpack, the path to entity is irrelevant in there. Let's merge, the change is definitely not problematic, it can't break anything, so I am fine merging without tests. |
@B4nan I understood your request, but I didn't have time yesterday to task switch, as I am still attempting to debug the underlying error that I ran into. I'm only seeing it in production, and so I was just dropping notes above on what I think might be causing it. Glad it was okay enough to merge. |
I haven't created a bug ticket for this, but I did explain the problem in this Slack thread.