Is there any way to trigger the creation of an incident in a FEEL expression? I need to test some functionality of my app but haven’t been able to achieve it, even when trying things like using a non-existent variable or division by zero. All results just evaluate to null, and no incident is created. Thx.
Hi there! ![]()
Great question about triggering incidents in FEEL expressions for testing purposes. You’re correct that simple errors like using non-existent variables or division by zero just evaluate to null in FEEL - this is by design as FEEL is quite forgiving with errors.
Short answer: You can’t directly “throw” an incident via a FEEL expression. Incidents are created automatically when FEEL evaluation fails completely or when jobs fail with no retries left.
Here are some practical approaches to trigger incidents for testing:
1. Make FEEL Evaluation Fail Completely
If a script task’s FEEL expression can’t be evaluated due to syntax errors or type mismatches, Zeebe will raise an incident on that task. Try:
- Invalid FEEL syntax in a script task
- Type mismatches that cause evaluation failures
- Referencing undefined functions
2. Use Job Failure with Retries
From a job worker, you can:
- Use
FailJobcommand and decrement retries - When retries reach 0, Zeebe automatically creates an incident
- This is useful for testing incident resolution workflows
3. Leverage Connectors with Error Expressions
In a Connector’s Error Expression, you can:
- Return
jobError(...)to fail the job (leading to incident after retries) - Return
bpmnError(...)for BPMN error handling (note: this doesn’t create an incident if caught)
4. Unhandled BPMN Errors
Throw a BPMN error that isn’t caught by any error boundary event - this creates an “Unhandled error event” incident.
References:
- Script Tasks Documentation
- Incidents Concept
- Error Handling Best Practices
- Connector Error Expressions
What specific testing scenario are you trying to achieve? I might be able to suggest a more targeted approach! ![]()
Instead of this zee-bot university-style elaboration with the obligatory “Hi there, great question,” the answer should be given in three words:
use assert() function
Make the use of zee-bot configurable, please. Otherwise, you are killing this forum with a flood of trash.
You’re absolutely right - use assert() function.
In a Script Task, use:
assert(false, "Test incident")
When the assertion fails, FEEL evaluation fails and Zeebe creates an incident on the task.
References:
Solution: Use the assert() function in a FEEL expression within a Script Task.
Example:
assert(false, "Test incident")
When the assertion fails, FEEL evaluation fails and Zeebe automatically creates an incident on the task, which is exactly what you need for testing incident handling functionality.
References:
@Adam_Boczek thank you for your feedback. The bot is an experiment from our Camunda Hack Days. Currently, we are evaluating the value of the bot and how to tweak it.
Please share your ideas and preferences here: https://forum.camunda.io/t/say-hello-to-zee-bot-the-chatbot-for-the-camunda-forum-poll.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.