Skip to content

Commit 374d50b

Browse files
committed
fix: do not try to find unresolved variables of a broken expression
Closes #50
1 parent 46ad474 commit 374d50b

File tree

3 files changed

+72
-2
lines changed

3 files changed

+72
-2
lines changed

lib/zeebe/util/feelUtility.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,15 @@ export function getResultContext(expression, variables = {}) {
141141
});
142142

143143
const contextualParser = parser.configure({
144-
contextTracker: customContextTracker
144+
contextTracker: customContextTracker,
145+
strict: true
145146
});
146147

147-
contextualParser.parse(expression);
148+
try {
149+
contextualParser.parse(expression);
150+
} catch (error) {
151+
return latestVariables;
152+
}
148153

149154
return latestVariables;
150155
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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">
3+
<bpmn:process id="Process_0j5qzil" name="Agent Blueprint (Long Term Memory)" isExecutable="true">
4+
<bpmn:serviceTask id="Task_1" name="Handle customer request">
5+
<bpmn:extensionElements>
6+
<zeebe:taskDefinition type="io.camunda.agenticai:aiagent:1" retries="3" />
7+
<zeebe:ioMapping>
8+
<zeebe:input source="=For **every** in-scope customer request:&#10;&#10;1. **Inspect** the full list of available tools. Typical tools include, but are not limited to: &#10; • `Reply with email to customer` – Give an answer to the customer’s email&#10; • `Query knowledge base` – Query knowledge base about a certain question. Use this when you need additional information about our oferring with regards to the customer enquiry. &#10; • `Ask a specialist` – You didn&#39;t find an answer to the customer&#39;s question and you need assitance from a human colleague. You will be able to learn from that colleague and save answer in the knowledge base for future interactions.&#10;&#10;3. **Invoke at least one relevant tool** &#10; • Call the same tool multiple times with different inputs if needed. &#10; • If no loan-specific tool fits, you **must** &#10; a. call a generic search / knowledge tool **or** &#10; b. escalate via `Ask a specialist`. &#10; • Only if the expert confirms that no tool can help may you answer from general knowledge. &#10; • Any choice to skip a potentially helpful tool must be justified inside `&#60;reflection&#62;`. &#10;4. **Communication mandate**: &#10; • To gather information from the **customer**, call `Reply with email to customer`.• To seek guidance from an **expert**, call `Ask a specialist`." target="target" />
9+
</zeebe:ioMapping>
10+
</bpmn:extensionElements>
11+
<bpmn:outgoing>Flow_1imcl82</bpmn:outgoing>
12+
</bpmn:serviceTask>
13+
<bpmn:sequenceFlow id="Flow_1imcl82" sourceRef="Task_1" targetRef="Task_2" />
14+
<bpmn:serviceTask id="Task_2">
15+
<bpmn:incoming>Flow_1imcl82</bpmn:incoming>
16+
</bpmn:serviceTask>
17+
</bpmn:process>
18+
<bpmndi:BPMNDiagram id="BPMNDiagram_1">
19+
<bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Process_0j5qzil">
20+
<bpmndi:BPMNShape id="Activity_1clcfsu_di" bpmnElement="Task_1" bioc:stroke="#0d4372" bioc:fill="#bbdefb" color:background-color="#bbdefb" color:border-color="#0d4372">
21+
<dc:Bounds x="153" y="80" width="100" height="80" />
22+
<bpmndi:BPMNLabel />
23+
</bpmndi:BPMNShape>
24+
<bpmndi:BPMNShape id="Activity_1a52niu_di" bpmnElement="Task_2">
25+
<dc:Bounds x="340" y="80" width="100" height="80" />
26+
</bpmndi:BPMNShape>
27+
<bpmndi:BPMNEdge id="BPMNEdge_06wqta8" bpmnElement="Flow_1imcl82">
28+
<di:waypoint x="253" y="120" />
29+
<di:waypoint x="340" y="120" />
30+
</bpmndi:BPMNEdge>
31+
</bpmndi:BPMNPlane>
32+
</bpmndi:BPMNDiagram>
33+
</bpmn:definitions>

test/spec/zeebe/ZeebeVariableResolver.spec.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import emptyXML from 'test/fixtures/zeebe/empty.bpmn';
1313
import complexXML from 'test/fixtures/zeebe/complex.bpmn';
1414
import connectorsXML from 'test/fixtures/zeebe/connectors.bpmn';
1515
import ioMappingsXML from 'test/fixtures/zeebe/ioMappings.bpmn';
16+
import longBrokenExpressionXML from 'test/fixtures/zeebe/long-broken-expression.bpmn';
1617

1718
import VariableProvider from 'lib/VariableProvider';
1819
import { getInputOutput } from '../../../lib/base/util/ExtensionElementsUtil';
@@ -1039,6 +1040,37 @@ describe('ZeebeVariableResolver', function() {
10391040

10401041
});
10411042

1043+
1044+
describe('parsing', function() {
1045+
1046+
beforeEach(bootstrapModeler(longBrokenExpressionXML, {
1047+
container,
1048+
additionalModules: [
1049+
ZeebeVariableResolverModule
1050+
],
1051+
moddleExtensions: {
1052+
zeebe: ZeebeModdle
1053+
}
1054+
}));
1055+
1056+
1057+
it('should NOT error on a long broken expression', inject(async function(elementRegistry, variableResolver) {
1058+
1059+
// given
1060+
const task = elementRegistry.get('Task_1');
1061+
const bo = getBusinessObject(task);
1062+
const input = getInputOutput(bo).inputParameters[1];
1063+
1064+
// when
1065+
const variables = await variableResolver.getVariablesForElement(bo, input);
1066+
1067+
// then
1068+
expect(variables).to.variableEqual([
1069+
{ name: 'target' }
1070+
]);
1071+
}));
1072+
});
1073+
10421074
});
10431075

10441076
// helpers //////////////////////

0 commit comments

Comments
 (0)