{"record":{"id":"e18ff521fd479da2","repo":"Activiti/Activiti","slug":"provided-exception-message-is-null-e18ff5","errorCode":null,"errorMessage":"Provided exception message is null","messagePattern":"Provided exception message is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/JobQueryImpl.java","lineNumber":181,"sourceCode":"            throw new ActivitiIllegalArgumentException(\"Provided date is null\");\n        }\n        this.duedateLowerThanOrEqual = date;\n        return this;\n    }\n\n    public JobQuery noRetriesLeft() {\n        noRetriesLeft = true;\n        return this;\n    }\n\n    public JobQuery withException() {\n        this.withException = true;\n        return this;\n    }\n\n    public JobQuery exceptionMessage(String exceptionMessage) {\n        if (exceptionMessage == null) {\n            throw new ActivitiIllegalArgumentException(\"Provided exception message is null\");\n        }\n        this.exceptionMessage = exceptionMessage;\n        return this;\n    }\n\n    public JobQuery jobTenantId(String tenantId) {\n        if (tenantId == null) {\n            throw new ActivitiIllegalArgumentException(\"job is null\");\n        }\n        this.tenantId = tenantId;\n        return this;\n    }\n\n    public JobQuery jobTenantIdLike(String tenantIdLike) {\n        if (tenantIdLike == null) {\n            throw new ActivitiIllegalArgumentException(\"job is null\");\n        }\n        this.tenantIdLike = tenantIdLike;","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/Activiti/Activiti/blob/56435b1a97deeafdc09dd40074b056c89fba5a8a/activiti-core/activiti-engine/src/main/java/org/activiti/engine/impl/JobQueryImpl.java#L163-L199","documentation":"JobQueryImpl.exceptionMessage(String) narrows the query to jobs whose last failure message matches the given text; a null message cannot be matched, so the engine throws ActivitiIllegalArgumentException when null is passed. To find jobs with any exception, use withException() instead of a null exception message.","triggerScenarios":"Calling createJobQuery().exceptionMessage(null), e.g. when the message comes from a failed stack-trace/message lookup that returned null, or from an absent search field in an admin UI.","commonSituations":"Operations dashboards for failed jobs where the 'error contains' field is empty (null) and passed through, propagating the message from a caught exception that was itself null (NPE-free catch of a null getMessage()), or copying fields between job DTOs.","solutions":["Only call exceptionMessage() when a non-null, non-empty message string is available","If you want any failed job regardless of message, call withException() instead of exceptionMessage(null)","Treat empty search input as 'no filter' rather than passing null","Trim and validate the message input at the UI/API layer before querying"],"exampleFix":"// before\nList<Job> failed = managementService.createJobQuery()\n    .withException()\n    .exceptionMessage(search.getMessage())\n    .list();\n// after\nJobQuery query = managementService.createJobQuery().withException();\nif (search.getMessage() != null && !search.getMessage().isEmpty()) {\n    query.exceptionMessage(search.getMessage());\n}\nList<Job> failed = query.list();","handlingStrategy":"validation","validationCode":"// Java\nif (message == null || message.isEmpty()) {\n    throw new IllegalArgumentException(\"exceptionMessage requires a non-null string; use withException() for any failure\");\n}","typeGuard":"// Java\nboolean hasExceptionFilter(JobSearch s) {\n    return s.getMessage() != null && !s.getMessage().trim().isEmpty();\n}","tryCatchPattern":"// Java\ntry {\n    jobs = managementService.createJobQuery().withException().exceptionMessage(msg).list();\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"exception message is null\")) {\n        jobs = managementService.createJobQuery().withException().list();\n    } else {\n        throw e;\n    }\n}","preventionTips":["Treat empty search fields as 'no filter' and skip the exceptionMessage() call","Use withException() alone when you want any failed job regardless of message text","Null-check getMessage() results from caught exceptions before propagating them into queries","Trim/normalize message input at the UI layer before it reaches the query builder"],"tags":["activiti","null-argument","query-validation","java"],"backgroundTag":"null-argument","analyzedSha":"56435b1a97deeafdc09dd40074b056c89fba5a8a","analyzedAt":"2026-09-09T21:00:06.703Z","contentChangedAt":"2026-09-09T21:00:06.703Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}