{"record":{"id":"897edabc29316976","repo":"flowable/flowable-engine","slug":"cannot-combine-onlymessages-with-onlyexternalwor","errorCode":null,"errorMessage":"Cannot combine onlyMessages() with onlyExternalWorkers() in the same query","messagePattern":"Cannot combine onlyMessages\\(\\) with onlyExternalWorkers\\(\\) in the same query","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/DeadLetterJobQueryImpl.java","lineNumber":464,"sourceCode":"            throw new FlowableIllegalArgumentException(\"Cannot combine onlyTimers() with onlyMessages() in the same query\");\n        }\n\n        if (onlyExternalWorkers) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyExternalWorkers() with onlyMessages() in the same query\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.onlyMessages = true;\n        } else {\n            this.onlyMessages = true;\n        }\n        return this;\n    }\n\n    @Override\n    public DeadLetterJobQueryImpl externalWorkers() {\n        if (onlyMessages) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyMessages() with onlyExternalWorkers() in the same query\");\n        }\n\n        if (onlyTimers) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyTimers() with onlyExternalWorkers() in the same query\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.onlyExternalWorkers = true;\n        } else {\n            this.onlyExternalWorkers = true;\n        }\n        return this;\n    }\n\n\n    @Override\n    public DeadLetterJobQueryImpl duedateHigherThan(Date date) {\n        if (date == null) {","sourceCodeStart":446,"sourceCodeEnd":482,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-job-service/src/main/java/org/flowable/job/service/impl/DeadLetterJobQueryImpl.java#L446-L482","documentation":"DeadLetterJobQueryImpl.externalWorkers() rejects a query that already narrowed to message jobs. If the onlyMessages flag is set, calling externalWorkers() would combine two exclusive categories, so FlowableIllegalArgumentException is thrown. A dead-letter job query can target only one job category.","triggerScenarios":"Calling deadLetterJobQuery().messages() ... .externalWorkers(). The check fires in externalWorkers() when onlyMessages is true.","commonSituations":"Building the filter chain conditionally where multiple category flags can be requested; code reuse where a query configured for messages is later extended for external workers.","solutions":["Use only one of messages(), timers(), externalWorkers() per query","Pick the category once with if/else logic before chaining other criteria","Start a new DeadLetterJobQueryImpl for a different category"],"exampleFix":"// before\nDeadLetterJobQuery q = mgmt.createDeadLetterJobQuery().messages();\nif (useExternal) { q.externalWorkers(); }\n// after\nDeadLetterJobQuery q = useExternal ? mgmt.createDeadLetterJobQuery().externalWorkers() : mgmt.createDeadLetterJobQuery().messages();","handlingStrategy":"validation","validationCode":"if (useMessages && useExternalWorkers) { throw new IllegalArgumentException(\"messages() and externalWorkers() are mutually exclusive\"); }","typeGuard":null,"tryCatchPattern":"try { query = mgmt.createDeadLetterJobQuery().externalWorkers(); } catch (FlowableIllegalArgumentException e) { log.error(\"Conflicting category filters\", e); }","preventionTips":["Choose one of messages()/timers()/externalWorkers() per query","Use an enum JobCategory instead of independent booleans","Unit-test query building with all flag combinations"],"tags":["flowable","job-query","illegal-argument","query-builder"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}