flowable/flowable-engine · error · FlowableIllegalArgumentException
Task id should not be null
Error message
Task id should not be null
What it means
FlowableIllegalArgumentException thrown by GetRenderedTaskFormCmd.execute as a precondition check: the taskId supplied to the command is null. Nothing is looked up; the command fails fast because rendering a task form is impossible without a task id.
Solutions
- Ensure a non-null task id is passed: obtain it from taskService.createTaskQuery()...singleResult().getId() or from a persisted TaskEntity.
- Add a null/blank check in the calling code before invoking the form API.
- If the task is created programmatically, call taskService.saveTask(task) first so it receives a database id.
Example fix
// before
String id = myTask != null ? myTask.getId() : null;
Object form = formService.getRenderedTaskForm(id);
// after
if (myTask == null || myTask.getId() == null) {
throw new IllegalArgumentException("A persisted task is required");
}
Object form = formService.getRenderedTaskForm(myTask.getId()); Defensive patterns
Strategy: validation
Validate before calling
if (taskId == null || taskId.isBlank()) {
throw new IllegalArgumentException("taskId must be a persisted, non-null id");
} Type guard
boolean hasValidTaskId(Task t) { return t != null && t.getId() != null && !t.getId().isEmpty(); } Try / catch
try {
return formService.getRenderedTaskForm(taskId);
} catch (FlowableIllegalArgumentException e) {
if (e.getMessage().contains("Task id should not be null")) { /* reject request before engine call next time */ }
} Prevention
- Save transient tasks via taskService.saveTask() before rendering forms.
- Null-check task.getId() when a Task object may be unsaved.
- Never pass a nullable variable straight into the form API.
- Validate request parameters at the API boundary.
When it happens
Trigger: Calling formService.getRenderedTaskForm(taskId) (with or without a form engine name) passing null — typically an uninitialized variable, a Task object whose getId() returned null, or an unsaved transient task.
Common situations: Passing task.getId() of a task created in Java but not yet saved through the task service; a mapping layer that dropped the id; forgetting to assign the result of taskService.createTaskQuery() before rendering the form.
Related errors
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/be78cf20dd391623.
Report an issue: GitHub.
Appendix: source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetRenderedTaskFormCmd.java:51
* @author Tom Baeyens
* @author Joram Barrez
*/
public class GetRenderedTaskFormCmd implements Command<Object>, Serializable {
private static final long serialVersionUID = 1L;
protected String taskId;
protected String formEngineName;
public GetRenderedTaskFormCmd(String taskId, String formEngineName) {
this.taskId = taskId;
this.formEngineName = formEngineName;
}
@Override
public Object execute(CommandContext commandContext) {
if (taskId == null) {
throw new FlowableIllegalArgumentException("Task id should not be null");
}
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
TaskEntity task = processEngineConfiguration.getTaskServiceConfiguration().getTaskService().getTask(taskId);
if (task == null) {
throw new FlowableObjectNotFoundException("Task '" + taskId + "' not found", Task.class);
}
FormHandlerHelper formHandlerHelper = processEngineConfiguration.getFormHandlerHelper();
TaskFormHandler taskFormHandler = formHandlerHelper.getTaskFormHandlder(task);
if (taskFormHandler != null) {
FormEngine formEngine = processEngineConfiguration.getFormEngines().get(formEngineName);
if (formEngine == null) {
throw new FlowableException("No formEngine '" + formEngineName + "' defined process engine configuration");
}
View on GitHub (pinned to d6d39ce1c6)