{"record":{"id":"0ceb8abcaddf2a1e","repo":"flowable/flowable-engine","slug":"provided-useragentlike-is-null","errorCode":null,"errorMessage":"Provided userAgentLike is null","messagePattern":"Provided userAgentLike is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/TokenQueryImpl.java","lineNumber":146,"sourceCode":"            throw new FlowableIllegalArgumentException(\"Provided ipAddressLike is null\");\n        }\n        this.ipAddressLike = ipAddressLike;\n        return this;\n    }\n\n    @Override\n    public TokenQuery userAgent(String userAgent) {\n        if (userAgent == null) {\n            throw new FlowableIllegalArgumentException(\"Provided user agent is null\");\n        }\n        this.userAgent = userAgent;\n        return this;\n    }\n\n    @Override\n    public TokenQuery userAgentLike(String userAgentLike) {\n        if (userAgentLike == null) {\n            throw new FlowableIllegalArgumentException(\"Provided userAgentLike is null\");\n        }\n        this.userAgentLike = userAgentLike;\n        return this;\n    }\n\n    @Override\n    public TokenQuery userId(String userId) {\n        if (userId == null) {\n            throw new FlowableIllegalArgumentException(\"Provided user id is null\");\n        }\n        this.userId = userId;\n        return this;\n    }\n\n    @Override\n    public TokenQuery userIdLike(String userIdLike) {\n        if (userIdLike == null) {\n            throw new FlowableIllegalArgumentException(\"Provided userIdLike is null\");","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/TokenQueryImpl.java#L128-L164","documentation":"TokenQueryImpl.userAgentLike(String) adds a fuzzy-match (LIKE) criterion on the token's user agent. Passing null is rejected with FlowableIllegalArgumentException because a null 'like' pattern is meaningless and would be ambiguous with not filtering at all. The check is done eagerly when building the query.","triggerScenarios":"Calling TokenQuery.userAgentLike(null) inside a createTokenQuery() chain, usually with a variable or optional filter value that is null.","commonSituations":"Dynamic search forms where the 'user agent contains' field is optional; mapping a search DTO whose property was never set; copy-pasted query-building code applying all criteria unconditionally.","solutions":["Pass a non-null pattern, e.g. \"%Chrome%\" for substring matching.","Conditionally apply the criterion only when the filter value is non-null.","If the caller intended 'match everything', omit userAgentLike entirely instead of passing null."],"exampleFix":"// before\nTokenQuery q = identityService.createTokenQuery().userAgentLike(filter.userAgentLike);\n\n// after\nTokenQuery q = identityService.createTokenQuery();\nif (filter.userAgentLike != null) {\n    q = q.userAgentLike(\"%\" + filter.userAgentLike + \"%\");\n}","handlingStrategy":"validation","validationCode":"if (userAgentLike == null) { userAgentLike = \"%\"; } // or skip the call\nidentityService.createTokenQuery().userAgentLike(userAgentLike);","typeGuard":"boolean hasPattern(String v) { return v != null && !v.isEmpty(); }","tryCatchPattern":"try {\n    query.userAgentLike(pattern);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"userAgentLike is null\")) { /* skip criterion */ } else { throw e; }\n}","preventionTips":["Centralize LIKE-pattern construction (add % wildcards) in one null-checked utility.","Skip criteria instead of passing null for optional filters.","Add unit tests for search methods with absent filter fields."],"tags":["null-check","query-builder","idm-engine","java"],"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"}