Entity.forEach throws Error: Cannot get metadata
Describe the bug
When calling entity.forEachProperty, I am getting an error: 'Cannot get metadata for PipeworkPhysical:PipingPhysicalTypeUsesPortTypes'.
This is a regression from iTwinJS 4
To Reproduce Steps to reproduce the behavior:
- Open a briefcase,
- query for the relationship
entity = iModel.relationships.getInstance("PipeworkPhysical:PipingPhysicalTypeUsesPortTypes", "0x2000000022b") - call
entity.forEachProperty((propName, propMeta) => {});
This will cause the error.
Expected behavior Should not error.
Desktop (please complete the applicable information):
- OS: Windows
- Browser: Electron
- iTwin.js Version: 5.0.0-dev.118
Additional context Error is coming from Entity.ts#L233
Please consider this a high priority.
@khanaffan, will you please help with this?
Most likely unrelated, but there were changes to TypeScript config in 5.0, which affected classes derived from Entity class.
So if you're using tsconfig from @itwin/build-tools and have classes derived from Entity class, see changelog.
Thanks @GytisCepk. The entity object comes directly from core using iModel.relationships.getInstance, so if that is the issue, it would need to be fixed in this repo.
@simihartstein
Is the Cannot get metadata for PipeworkPhysical:PipingPhysicalTypeUsesPortTypes error coming from forEachProperty() or the new forEach()? It seems forEachProperty() is deprecated in 5.0 and recommends forEach() as a replacement. When calling forEachProperty() in 4.11 and forEachProperty() in 5.0 I receive no error. I was able to reproduce the Cannot get metadata error when there is no metadata defined when I call the new forEach() in 5.0.
Can you verify if the error you are seeing is coming from forEachProperty() or forEach() in 5.0? Your link points to forEach() in Entity, not forEachProperty(). If you are using forEach() maybe we can try using the deprecated forEachProperty() in 5.0 in the meanwhile. I will investigate if the error is intended when calling forEach()
@MichaelSwigerAtBentley
Hi Michael. Sorry for the delay and confusion. Despite the Github issue title (that I corrected), I am using the new Entity.forEach in 5.0.
I am travelling and won't have time until Friday to test thoroughly, but I can at least confirm I don't get an error using the deprecated forEachProperty
Hi Michael. Sorry for the delay and confusion. Despite the Github issue title (that I corrected), I am using the new
Entity.forEachin 5.0.I am travelling and won't have time until Friday to test thoroughly, but I can at least confirm I don't get an error using the deprecated forEachProperty
No worries. I have followed up with @rschili and we believe we have located the issue with forEach(). I am working on a fix right now.
PR: https://github.com/iTwin/itwinjs-core/pull/8277
I can still reproduce this as of 5.0.4. I can send you a briefcase with the issue if that would help
I can still reproduce this as of 5.0.4. I can send you a briefcase with the issue if that would help
This fix is not in 5.0.4. I just ckecked. I think you need 5.1. We should probably backport this @MichaelSwigerAtBentley @aruniverse
Ah. I thought this had been backported. I updated to 5.1 and can confirm it's fixed!