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

bpmnReplace fails when custom meta model uses a String array #1518

Closed
alexbisaillion opened this issue Nov 3, 2021 · 4 comments · Fixed by #1647
Closed

bpmnReplace fails when custom meta model uses a String array #1518

alexbisaillion opened this issue Nov 3, 2021 · 4 comments · Fixed by #1647
Assignees
Labels
bug Something isn't working pr welcome We rely on a community contribution to improve this. spring cleaning Could be cleaned up one day

Comments

@alexbisaillion
Copy link

Describe the Bug

I am using a custom meta model that has a property of type String and isMany set to true. I am attempting to call bpmnReplace (from modeler.get("bpmnReplace")) and an error is being thrown when the element is being copied:

The error prevents the element from being replaced.

I set up an example reproduction using one of the bpmn example repos. Here's a fork of it.

It is worth noting that the example repo was using bpmn-js v3.2.1, where the issue does not happen:

It happens with v8.8.2, so it looks like it is a regression.

Steps to Reproduce

  1. Clone my example repo available here
  2. Run the example as normal (npm install && npm start)
  3. Click the "Do work" task
  4. Click "Make task" in the properties panel. The call to bpmnReplace will fail.

Expected Behavior

The task should be replaced successfully.

Environment

  • Browser: Chrome Version 95.0.4638.54
  • OS: Windows 10
  • Library version: 8.8.2
@alexbisaillion alexbisaillion added the bug Something isn't working label Nov 3, 2021
@alexbisaillion alexbisaillion changed the title bpmnReplace fails when custom meta model has uses a String array bpmnReplace fails when custom meta model uses a String array Nov 3, 2021
@pinussilvestrus
Copy link
Contributor

pinussilvestrus commented Nov 15, 2021

Thanks for reporting! Sorry for not reaching out to you.

So you have the following metamodel

{
  "name": "AnalysisDetails",
  "superClass": [ "Element" ],
  "properties": [
    {
      "name": "path",
      "type": "String",
      "isMany": true
    }
  ]
}

How should the resulting XML look like? Something like this?

<analysisDetails path=[ "one", "two", "three" ] />

I'm not even sure, whether this is possible, syntax-wise. When you want to have a collection attribute, why you don't do it like this

{
  "name": "Path",
  "superClass": [ "Element" ],
  "properties": [
    {
      "name": "value",
      "isBody": true,
      "type": "String"
    }
  ]
},
{
  "name": "AnalysisDetails",
  "superClass": [ "Element" ],
  "properties": [
    {
      "name": "path",
      "type": "Path",
      "isMany": true
    }
  ]
}

That would result in what you also defined in your example diagram

<qa:analysisDetails>
  <qa:path>A</qa:path>
  <qa:path>B</qa:path>
  <qa:path>C</qa:path>
</qa:analysisDetails>

Does this resolve your error?

@pinussilvestrus pinussilvestrus added the help wanted Extra attention is needed label Nov 15, 2021
@alexbisaillion
Copy link
Author

Hi there! So the resulting xml should indeed look like how I have it defined in the example diagram, so something like this:

<qa:analysisDetails>
  <qa:path>A</qa:path>
  <qa:path>B</qa:path>
  <qa:path>C</qa:path>
</qa:analysisDetails>

The main issue I would have with defining it as you suggested would be that it doesn't map well to our XML schema, which we use to create the moddle descriptor.

This should be valid in an XML schema definition:
<xsd:element name="path" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>

And I think it should map to what I had in the meta model:

{
  "name": "AnalysisDetails",
  "superClass": [ "Element" ],
  "properties": [
    {
      "name": "path",
      "type": "String",
      "isMany": true
    }
  ]
}

I think your suggested meta model would look more like this in an xml schema:
<xsd:element name="path" type="Path" minOccurs="0" maxOccurs="unbounded"/> .
And you would need another type defined in the definition for Path.

And we have been saving/updating these elements on our diagrams with no problems, except for this instance where bpmnReplace is failing.

@pinussilvestrus
Copy link
Contributor

Thanks for sharing!

I checked our moddle-xml library we use for the XML parsing and verified that we actually support the case you've mentioned. Notice that we have test cases for reading and writing string arrays.

So indeed, that seems to be a bug in bpmn-js#ModdleCopy to cover this case. The reason for it could be that we actually don't use this format for our BPMN 2.0 descriptors, but we don't encourage that one for custom element extensions.

Since there is a workaround, I will move that one to backlog. We are open to contributions that improve the situation!

I'll likely follow up with a test case that reproduces the problem.

@pinussilvestrus pinussilvestrus added backlog Queued in backlog and removed help wanted Extra attention is needed labels Nov 23, 2021
pinussilvestrus pushed a commit that referenced this issue Nov 23, 2021
@pinussilvestrus
Copy link
Contributor

pinussilvestrus commented Nov 23, 2021

With 832f920 I added a simple test case that show cases the broken behavior.

Branch: https://github.com/bpmn-io/bpmn-js/tree/string-array-moddle

@pinussilvestrus pinussilvestrus added pr welcome We rely on a community contribution to improve this. spring cleaning Could be cleaned up one day labels Nov 23, 2021
pinussilvestrus pushed a commit that referenced this issue Nov 23, 2021
@Skaiir Skaiir self-assigned this May 17, 2022
Skaiir pushed a commit that referenced this issue May 17, 2022
@bpmn-io-tasks bpmn-io-tasks bot added in progress Currently worked on and removed backlog Queued in backlog labels May 17, 2022
Skaiir pushed a commit that referenced this issue May 17, 2022
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels May 17, 2022
@fake-join fake-join bot closed this as completed in #1647 May 20, 2022
fake-join bot pushed a commit that referenced this issue May 20, 2022
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label May 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working pr welcome We rely on a community contribution to improve this. spring cleaning Could be cleaned up one day
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants