{"record":{"id":"cdb0e3272bd5b420","repo":"flowable/flowable-engine","slug":"provided-exception-message-is-null-cdb0e3","errorCode":null,"errorMessage":"Provided exception message is null","messagePattern":"Provided exception message is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/HistoryJobQueryImpl.java","lineNumber":125,"sourceCode":"            this.handlerTypes = handlerTypes;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoryJobQuery withException() {\n        if (inOrStatement) {\n            this.currentOrQueryObject.withException = true;\n        } else {\n            this.withException = true;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoryJobQuery exceptionMessage(String exceptionMessage) {\n        if (exceptionMessage == null) {\n            throw new FlowableIllegalArgumentException(\"Provided exception message is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.exceptionMessage = exceptionMessage;\n        } else {\n            this.exceptionMessage = exceptionMessage;\n        }\n        return this;\n    }\n\n    @Override\n    public HistoryJobQuery scopeType(String scopeType) {\n        if (scopeType == null) {\n            throw new FlowableIllegalArgumentException(\"Provided scope type is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.scopeType = scopeType;\n        } else {\n            this.scopeType = scopeType;","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/HistoryJobQueryImpl.java#L107-L143","documentation":"HistoryJobQuery.exceptionMessage(String) rejects a null exception message with FlowableIllegalArgumentException. The exception-message filter is used to find history jobs that failed with a specific error, and the library requires a concrete non-null string for it.","triggerScenarios":"Calling historyJobQuery.exceptionMessage(null), directly or in an or() block, typically when the message comes from a caught exception whose getMessage() returned null or from an uninitialized field.","commonSituations":"Logging/handling failed jobs where exception.getMessage() is null (e.g. NPEs without messages); forwarding a nullable message from an error-handling layer; building admin queries to find jobs that failed with a given message.","solutions":["Only call exceptionMessage() when a non-null message is available; use exceptionMessageLike() or skip the filter otherwise","Guard: if (message != null) query.exceptionMessage(message)","If the source exception has a null message, substitute a fallback string like e.getClass().getName()","Use the stack trace class name instead of the message for filtering when messages are unreliable"],"exampleFix":"// before\nString msg = failedJob.getExceptionMessage(); // may be null\nquery.exceptionMessage(msg);\n// after\nif (msg != null) {\n    query.exceptionMessage(msg);\n}","handlingStrategy":"validation","validationCode":"String msg = exception != null ? exception.getMessage() : null;\nif (msg == null && exception != null) { msg = exception.getClass().getName(); }\nif (msg != null) { historyJobQuery.exceptionMessage(msg); }","typeGuard":"boolean hasExceptionMessage(String m) { return m != null && !m.isEmpty(); }","tryCatchPattern":"try {\n    query.exceptionMessage(message);\n} catch (FlowableIllegalArgumentException e) {\n    log.warn(\"exceptionMessage filter skipped: {}\", e.getMessage());\n}","preventionTips":["Remember exception.getMessage() can be null; use the class name as fallback","Apply the message filter conditionally","Normalize stored exception messages to non-null strings when persisting jobs"],"tags":["java","flowable","null-check","query-api"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}