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

CompensateBoundaryEventBehavior.js: fail 'shape.replace' event handler when the targetElement is undefined #2073

Closed
Vovamzur opened this issue Jan 7, 2024 · 5 comments · Fixed by #2074
Assignees
Labels
bug Something isn't working modeling

Comments

@Vovamzur
Copy link

Vovamzur commented Jan 7, 2024

Describe the Bug

There is a bug while using bpmn-js-element-templates with bpmn-js@16.3.0 after removing an element template:

EventBus.js:437 unhandled error in event listener TypeError: Cannot read properties of undefined (reading 'type')
    at handleReplacement (CompensateBoundaryEventBehavior.js:101:1)

It is caused by calling https://github.com/bpmn-io/bpmn-js-element-templates/blob/main/src/element-templates/cmd/RemoveElementTemplateHandler.js#L46 without hints.targetElement

As we can see from line https://github.com/bpmn-io/bpmn-js/blob/develop/lib/features/modeling/behavior/CompensateBoundaryEventBehavior.js#L95 the targetElement could be undefined.

As solution, we could check it for undefined before getting properties like targetElement.type or targetElement.eventDefinitionType on 100,101,115 lines

Steps to Reproduce

  1. apply some element template
  2. remove element template

Expected Behavior

Element template is removed without errors

Environment

  • Library version: 16.3.1
  • bpmn-js-element-templates: 1.10.0
@Vovamzur Vovamzur added the bug Something isn't working label Jan 7, 2024
@nikku
Copy link
Member

nikku commented Jan 8, 2024

I can reproduce this in the bpmn-js-element-templates test environment:

  • spin it up using npm start
  • assign an element template to a compensation activity
  • remove element template from a compensation activity

capture uS3OzT_optimized

@nikku
Copy link
Member

nikku commented Jan 8, 2024

We see these failures when updating the element template repository dependencies, too: bpmn-io/bpmn-js-element-templates#40

@nikku nikku added the ready Ready to be worked on label Jan 8, 2024
@barmac
Copy link
Member

barmac commented Jan 9, 2024

This sounds critical :/

@nikku nikku added the modeling label Jan 9, 2024
@barmac
Copy link
Member

barmac commented Jan 9, 2024

I had a closer look, and in the compensation PR I assumed that targetElement is set but it's only done when replacing via bpmnReplace. We should probably look at the newData property instead as it's set in the core diagram-js component.

barmac added a commit that referenced this issue Jan 9, 2024
@bpmn-io-tasks bpmn-io-tasks bot added the in progress Currently worked on label Jan 9, 2024
@bpmn-io-tasks bpmn-io-tasks bot removed the ready Ready to be worked on label Jan 9, 2024
@bpmn-io-tasks bpmn-io-tasks bot added needs review Review pending and removed in progress Currently worked on labels Jan 9, 2024
nikku pushed a commit that referenced this issue Jan 9, 2024
@barmac
Copy link
Member

barmac commented Jan 9, 2024

Closed via #2074

@barmac barmac closed this as completed Jan 9, 2024
@bpmn-io-tasks bpmn-io-tasks bot removed the needs review Review pending label Jan 9, 2024
nikku added a commit to bpmn-io/bpmn-js-element-templates that referenced this issue Jan 9, 2024
Fixes a replace issue (originally reported via bpmn-io/bpmn-js#2073).
barmac pushed a commit to bpmn-io/bpmn-js-element-templates that referenced this issue Jan 10, 2024
Fixes a replace issue (originally reported via bpmn-io/bpmn-js#2073).
nikku added a commit to camunda/camunda-bpmn-js that referenced this issue Jan 22, 2024
nikku added a commit to camunda/camunda-bpmn-js that referenced this issue Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working modeling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants