{"record":{"id":"dc855ce9253af873","repo":"flowable/flowable-engine","slug":"cannot-combine-onlyoutbound-with-onlyinbound-i","errorCode":null,"errorMessage":"Cannot combine onlyOutbound() with onlyInbound() in the same query","messagePattern":"Cannot combine onlyOutbound\\(\\) with onlyInbound\\(\\) in the same query","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/ChannelDefinitionQueryImpl.java","lineNumber":258,"sourceCode":"    @Override\n    public ChannelDefinitionQueryImpl latestVersion() {\n        this.latest = true;\n        return this;\n    }\n    \n    @Override\n    public ChannelDefinitionQuery onlyInbound() {\n        if (onlyOutbound) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyInbound() with onlyOutbound() in the same query\");\n        }\n        this.onlyInbound = true;\n        return this;\n    }\n\n    @Override\n    public ChannelDefinitionQuery onlyOutbound() {\n        if (onlyInbound) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine onlyOutbound() with onlyInbound() in the same query\");\n        }\n        this.onlyOutbound = true;\n        return this;\n    }\n\n    @Override\n    public ChannelDefinitionQuery implementation(String implementation) {\n        if (implementation == null) {\n            throw new FlowableIllegalArgumentException(\"implementation is null\");\n        }\n        this.implementation = implementation;\n        return this;\n    }\n\n    @Override\n    public ChannelDefinitionQueryImpl channelCreateTime(Date createTime) {\n        this.createTime = createTime;\n        return this;","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-event-registry/src/main/java/org/flowable/eventregistry/impl/ChannelDefinitionQueryImpl.java#L240-L276","documentation":"ChannelDefinitionQueryImpl.onlyOutbound() throws FlowableIllegalArgumentException if onlyInbound() was already called on the same query. The inbound/outbound direction filters are mutually exclusive; setting both on one ChannelDefinitionQuery is a contradiction, so the second call fails fast with a clear message.","triggerScenarios":"Calling query.onlyInbound().onlyOutbound() (in either order), or code paths that add the outbound filter after the inbound filter was applied earlier in the builder chain.","commonSituations":"Dynamic query assembly accumulating filters from user-selected checkboxes (both 'inbound' and 'outbound' selected); duplicated filter code after refactoring.","solutions":["Apply only one directional filter per query instance","If both directions are needed, drop both filters to query all definitions and filter results in Java, or run two queries","Validate mutually exclusive options before building the query","Start a fresh ChannelDefinitionQuery when switching direction"],"exampleFix":"// before\nquery.onlyInbound();\nquery.onlyOutbound(); // throws\n// after\nif (direction.equals(\"inbound\")) {\n    query.onlyInbound();\n} else if (direction.equals(\"outbound\")) {\n    query.onlyOutbound();\n}","handlingStrategy":"validation","validationCode":"if (wantInbound && wantOutbound) {\n    throw new IllegalArgumentException(\"onlyOutbound cannot follow onlyInbound on the same query\");\n}\nif (wantOutbound) {\n    query.onlyOutbound();\n}","typeGuard":"boolean directionNotSet(ChannelDefinitionQueryImpl q) {\n    return !q.isOnlyInboundSet() && !q.isOnlyOutboundSet();\n}","tryCatchPattern":"try {\n    query.onlyOutbound();\n} catch (FlowableIllegalArgumentException e) {\n    logger.warn(\"Conflicting direction filters: {}\", e.getMessage());\n    query = channelDefinitionQuery().onlyOutbound(); // rebuild cleanly\n}","preventionTips":["Never chain onlyInbound() and onlyOutbound() on one query instance","Track the chosen direction in a single variable/enum instead of separate flags","Rebuild a fresh query object when the direction changes","Document the exclusivity in wrapper/service APIs that expose direction filtering"],"tags":["flowable","mutually-exclusive","query-builder","invalid-state"],"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-14T11:17:12.474Z"}