bpmn-io / bpmn-io/moddle

Exception in DescriptorBuilder when inherited properties have the same name

Open
#36 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backlog bug
Dominant language
JavaScript
Stars
111
Forks
33
PR merge metrics
No merged PRs in 30d

Description

Hi,

the DescriptorBuilder throws an exception if a property with the same name is defined in the inheritance chain of more than one of its super classes:

Error: property <any> already defined; override of <mh:AnotherRoot#mh:any> by <props:Root#props:any> not allowed without redefines
      at DescriptorBuilder._fd7‍.r.DescriptorBuilder.assertNotDefined (lib/descriptor-builder.js:180:11)
      at DescriptorBuilder._fd7‍.r.DescriptorBuilder.addNamedProperty (lib/descriptor-builder.js:138:10)
      at DescriptorBuilder._fd7‍.r.DescriptorBuilder.addProperty (lib/descriptor-builder.js:53:8)
      at DescriptorBuilder.<anonymous> (lib/descriptor-builder.js:227:12)
      at forEach (node_modules/min-dash/dist/index.js:170:20)
      at DescriptorBuilder._fd7‍.r.DescriptorBuilder.addTrait (lib/descriptor-builder.js:202:3)
      at lib/registry.js:185:13
      at Registry._0ac‍.r.Registry.mapTypes (lib/registry.js:165:3)
      at traverseSuper (lib/registry.js:155:10)
      at forEach (node_modules/min-dash/dist/index.js:170:20)
      at Registry._0ac‍.r.Registry.mapTypes (lib/registry.js:162:3)
      at Registry._0ac‍.r.Registry.getEffectiveDescriptor (lib/registry.js:184:8)
      at Moddle._1b8‍.r.Moddle.getType (lib/moddle.js:97:32)
      at Moddle._1b8‍.r.Moddle.create (lib/moddle.js:65:19)
      at Context.<anonymous> (test/spec/properties.js:589:34)
      at processImmediate (internal/timers.js:461:21)

I created a test case with a simplified hierarchy:
multiple-inherited-properties

mh:MultipleInherited has two properties named any:

  • mh:AnotherRoot#any
  • props:Root#any

and the DescriptorBuilder does not map them into seperate namespaces.

In my use-case, the problem occurs with the UMLDI meta-model, where all the diagram types inherit from UMLDI:UMLDiagram:
umldi-inheritance

Regards,
Frank

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the reproducer linked in commit b1b9795512d67f3bab3e7135068ad52f8c552f1d and test/spec/properties.js around the reported failure at line 589. Read lib/descriptor-builder.js, especially addProperty, addNamedProperty, assertNotDefined, and addTrait, along with the inheritance traversal in lib/registry.js. Done means the MultipleInherited hierarchy no longer throws when inherited properties share a name and both properties are mapped into separate namespaces.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.