flowable/flowable-engine · error · FlowableIllegalArgumentException
comment is null
Error message
comment is null
What it means
SaveCommentCmd.execute validates the Comment passed in before persisting. Flowable throws FlowableIllegalArgumentException('comment is null') when the comment object itself is null, because there is nothing to save and the update would fail downstream. It is an argument-validation guard at the start of the command.
Source
Thrown at modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/SaveCommentCmd.java:40
import org.flowable.engine.impl.persistence.entity.CommentEntityManager;
import org.flowable.engine.impl.util.CommandContextUtil;
/**
* @author Tijs Rademakers
*/
public class SaveCommentCmd implements Command<Void>, Serializable {
private static final long serialVersionUID = 1L;
protected CommentEntity comment;
public SaveCommentCmd(CommentEntity comment) {
this.comment = comment;
}
@Override
public Void execute(CommandContext commandContext) {
if (comment == null) {
throw new FlowableIllegalArgumentException("comment is null");
}
if (comment.getId() == null) {
throw new FlowableIllegalArgumentException("comment id is null");
}
CommentEntityManager commentEntityManager = CommandContextUtil.getCommentEntityManager(commandContext);
String eventMessage = comment.getFullMessage().replaceAll("\\s+", " ");
if (eventMessage.length() > 163) {
eventMessage = eventMessage.substring(0, 160) + "...";
}
comment.setMessage(eventMessage);
commentEntityManager.update(comment);
return null;
}
}View on GitHub (pinned to d6d39ce1c6)
Solutions
- Ensure a non-null Comment/CommentEntity is created or fetched before calling saveComment.
- Check the code path that produced the comment for a null return (e.g. createComment result ignored).
- If updating an existing comment, fetch it via getComment(id) and verify non-null first.
Example fix
// before
Comment comment = taskService.getComment(commentId); // may be null
comment.setFullMessage("updated");
taskService.saveComment(comment);
// after
Comment comment = taskService.getComment(commentId);
if (comment == null) {
throw new IllegalStateException("Comment " + commentId + " not found");
}
comment.setFullMessage("updated");
taskService.saveComment(comment); Defensive patterns
Strategy: validation
Validate before calling
if (comment == null) { throw new IllegalArgumentException("comment must be non-null before saveComment"); } Type guard
if (comment instanceof Comment && comment != null) { /* safe to save */ } Try / catch
try {
taskService.saveComment(comment);
} catch (FlowableIllegalArgumentException e) {
if (e.getMessage().contains("comment is null")) {
comment = taskService.addComment(taskId, processInstanceId, message);
}
} Prevention
- Never pass a lookup result directly to saveComment without a null check
- Use createComment/addComment for new comments
- Log and handle deleted-comment lookups explicitly
When it happens
Trigger: Calling TaskService.saveComment(null) or executing SaveCommentCmd with a null comment reference.
Common situations: Comment loaded by id returned null (record deleted) and then passed to saveComment; a lookup helper returning null instead of a fresh CommentEntity.
Related errors
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/52f5525904d9e229.
Report an issue: GitHub.