CustomRuleProvider connection.create problem

Hello everyone!
I’m having a problem setting a rule in a class I created called CustomRuleProvider that extends RuleProvider. I have defined two rules: one for shape.create and another for connection.create. The rule for shape.create works correctly, but the one for connection.create does not. In fact, when I want to create a sequence flow from the context pad or the pallette, I get many errors in the console, which are these:
Captura de pantalla 2023-12-20 a la(s) 17.43.01

This is something similar to the code I have in the rule:

this.addRule('connection.create', 1500, function(context) {
      let result = ElementIDService.verifyID(context);
        return result; // always boolean result
    });

On the other hand, if I have something like this instead, it works perfectly:

this.addRule('connection.create', 1500, function(context) {
      return false;
    });

Does anyone have an idea how to solve this?

Any truthy result returned by the connection.create rule must be an object with a type property, for example: { type: 'bpmn:SequenceFlow' }. You can see that in action here: bpmn-js/lib/features/rules/BpmnRules.js at develop · bpmn-io/bpmn-js · GitHub The corresponding type is defined here: bpmn-js/lib/features/rules/BpmnRules.js at develop · bpmn-io/bpmn-js · GitHub

That worked! Thank you so much :slight_smile:
But I want to add that although the previous error was solved, now this other one appears:
Captura de pantalla 2023-12-21 a la(s) 09.29.28

Do you know what it could be?

Can you share the custom code you’re using to create the connection? As you can see there are some NaNs which lead to an error. Probably the waypoints of the new connection?

Hello again!
The only custom code I have for the sequence flows creation (although it does not edit the waypoints) is in a class that extends CommandInterceptor with a postExecute(“create.connection”…). But when I debug, this error occurs before that postExecute function. Doing a little more research, it seems that the error is indeed coming from the connection waypoints, particularly in this function from bpmn-js/lib/draw/BpmnRenderer.js:
Captura de pantalla 2023-12-21 a la(s) 13.03.02

What I don’t understand is why this error began to happen after incorporating this custom rule in CustomRuleProvider. Here I show you how I defined the rule after the first solution you provided me:

this.addRule('connection.create', 1500, function(context) {
      let result;
      result = ElementIDService.verifyID(context); //boolean result
      if (!result) {
        return result;
      }
      return { type: 'bpmn:SequenceFlow' };
    });

To add more details, this is the sequence flow with NaN values in waypoints
with the rule:

Captura de pantalla 2023-12-21 a la(s) 14.49.38

And this is the sequence flow without the rule:

Captura de pantalla 2023-12-21 a la(s) 14.50.12

Edit: for an unknown reason, I recently discovered that this error doesn´t occur in Firefox, but it does in others browsers such as Chrome and Brave

There must be some kind of custom behavior tampering with the waypoints. Are you sure you didn’t touch them?

Hello!
Yes, I´m sure. I have reviewed the project to find any custom behavior regarding the waypoints and I have not found anything. I can’t upload the project to a sandbox to show you because I don’t have permission to do it in my team.
In any case, I insist, the strangest thing is that this error occurs, for example, in Chrome or Brave, and not in Firefox, which are the browsers I have tried so far. :thinking:

The only custom code I have for the sequence flows creation (although it does not edit the waypoints) is in a class that extends CommandInterceptor with a postExecute