Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ All notable changes to [@bpmn-io/variable-resolver](https://github.com/bpmn-io/v

___Note:__ Yet to be released changes appear here._

## 1.3.6

* `FIX`: always return an instance of variables context in `getResultContext` ([#58](https://github.com/bpmn-io/variable-resolver/pull/58))

## 1.3.5

* `FIX`: do not try to find unresolved variables of a broken expression ([#50](https://github.com/bpmn-io/variable-resolver/issues/50))
Expand Down
2 changes: 1 addition & 1 deletion lib/zeebe/util/feelUtility.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function getResultContext(expression, variables = {}) {

// This is a hack to get the latest variables from the context tracker
// lezer does not automatically annotate the parse tree with the context
let latestVariables = null;
let latestVariables = contextTracker.start;

const customContextTracker = new ContextTracker({
start: contextTracker.start,
Expand Down
33 changes: 33 additions & 0 deletions test/fixtures/zeebe/immediately-broken-expression.bpmn
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.39.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.8.0">
<bpmn:process id="Process_0j5qzil" name="Agent Blueprint (Long Term Memory)" isExecutable="true">
<bpmn:serviceTask id="Task_1" name="Handle customer request">
<bpmn:outgoing>Flow_1imcl82</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1imcl82" sourceRef="Task_1" targetRef="TASK_WITH_IMMEDIATELY_BROKEN_EXPRESSION" />
<bpmn:serviceTask id="TASK_WITH_IMMEDIATELY_BROKEN_EXPRESSION" name="Broken `target` input">
<bpmn:extensionElements>
<zeebe:ioMapping>
<zeebe:input source="=..." target="target" />
</zeebe:ioMapping>
</bpmn:extensionElements>
<bpmn:incoming>Flow_1imcl82</bpmn:incoming>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0j5qzil">
<bpmndi:BPMNShape id="Activity_1clcfsu_di" bpmnElement="Task_1" bioc:stroke="#0d4372" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#0d4372">
<dc:Bounds x="153" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNShape id="Activity_1a52niu_di" bpmnElement="TASK_WITH_IMMEDIATELY_BROKEN_EXPRESSION">
<dc:Bounds x="340" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge id="BPMNEdge_06wqta8" bpmnElement="Flow_1imcl82">
<di:waypoint x="253" y="120" />
<di:waypoint x="340" y="120" />
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</bpmn:definitions>
6 changes: 3 additions & 3 deletions test/fixtures/zeebe/long-broken-expression.bpmn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:bioc="http://bpmn.io/schema/bpmn/biocolor/1.0" xmlns:color="http://www.omg.org/spec/BPMN/non-normative/color/1.0" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" id="Definitions_1" targetNamespace="http://bpmn.io/schema/bpmn" exporter="Camunda Modeler" exporterVersion="5.39.0" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.8.0">
<bpmn:process id="Process_0j5qzil" name="Agent Blueprint (Long Term Memory)" isExecutable="true">
<bpmn:serviceTask id="Task_1" name="Handle customer request">
<bpmn:serviceTask id="TASK_WITH_LONG_BROKEN_EXPRESSION" name="Long broken `target` input">
<bpmn:extensionElements>
<zeebe:taskDefinition type="io.camunda.agenticai:aiagent:1" retries="3" />
<zeebe:ioMapping>
Expand All @@ -10,14 +10,14 @@
</bpmn:extensionElements>
<bpmn:outgoing>Flow_1imcl82</bpmn:outgoing>
</bpmn:serviceTask>
<bpmn:sequenceFlow id="Flow_1imcl82" sourceRef="Task_1" targetRef="Task_2" />
<bpmn:sequenceFlow id="Flow_1imcl82" sourceRef="TASK_WITH_LONG_BROKEN_EXPRESSION" targetRef="Task_2" />
<bpmn:serviceTask id="Task_2">
<bpmn:incoming>Flow_1imcl82</bpmn:incoming>
</bpmn:serviceTask>
</bpmn:process>
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0j5qzil">
<bpmndi:BPMNShape id="Activity_1clcfsu_di" bpmnElement="Task_1" bioc:stroke="#0d4372" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#0d4372">
<bpmndi:BPMNShape id="Activity_1clcfsu_di" bpmnElement="TASK_WITH_LONG_BROKEN_EXPRESSION" bioc:stroke="#0d4372" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#0d4372">
<dc:Bounds x="153" y="80" width="100" height="80" />
<bpmndi:BPMNLabel />
</bpmndi:BPMNShape>
Expand Down
76 changes: 55 additions & 21 deletions test/spec/zeebe/ZeebeVariableResolver.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import complexXML from 'test/fixtures/zeebe/complex.bpmn';
import connectorsXML from 'test/fixtures/zeebe/connectors.bpmn';
import ioMappingsXML from 'test/fixtures/zeebe/ioMappings.bpmn';
import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.bpmn';
import immediatelyBrokenExpressionXML from 'test/fixtures/zeebe/immediately-broken-expression.bpmn';

import VariableProvider from 'lib/VariableProvider';
import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil';
Expand Down Expand Up @@ -1043,32 +1044,65 @@ describe('ZeebeVariableResolver', function() {

describe('parsing', function() {

beforeEach(bootstrapModeler(longBrokenExpressionXML, {
container,
additionalModules: [
ZeebeVariableResolverModule
],
moddleExtensions: {
zeebe: ZeebeModdle
}
}));
describe('long broken expression', function() {

beforeEach(bootstrapModeler(longBrokenExpressionXML, {
container,
additionalModules: [
ZeebeVariableResolverModule
],
moddleExtensions: {
zeebe: ZeebeModdle
}
}));

it('should NOT error on a long broken expression', inject(async function(elementRegistry, variableResolver) {

// given
const task = elementRegistry.get('Task_1');
const bo = getBusinessObject(task);
const input = getInputOutput(bo).inputParameters[1];
it('should NOT error on a long broken expression', inject(async function(elementRegistry, variableResolver) {

// when
const variables = await variableResolver.getVariablesForElement(bo, input);
// given
const task = elementRegistry.get('TASK_WITH_LONG_BROKEN_EXPRESSION');
const bo = getBusinessObject(task);

// then
expect(variables).to.variableEqual([
{ name: 'target' }
]);
}));
// when
const variables = await variableResolver.getVariablesForElement(bo);

// then
expect(variables).to.variableEqual([
{ name: 'target' }
]);
}));

});


describe('immediately broken expression', function() {

beforeEach(bootstrapModeler(immediatelyBrokenExpressionXML, {
container,
additionalModules: [
ZeebeVariableResolverModule
],
moddleExtensions: {
zeebe: ZeebeModdle
}
}));


it('should NOT error on an immediate syntax error', inject(async function(elementRegistry, variableResolver) {

// given
const task = elementRegistry.get('TASK_WITH_IMMEDIATELY_BROKEN_EXPRESSION');
const bo = getBusinessObject(task);

// when
const variables = await variableResolver.getVariablesForElement(bo);

// then
expect(variables).to.variableEqual([
{ name: 'target' }
]);
}));
});
});

});
Expand Down