{"record":{"id":"48bfd7c5651fd164","repo":"quarkusio/quarkus","slug":"pattern-must-not-be-null-48bfd7","errorCode":null,"errorMessage":"Pattern must not be null","messagePattern":"Pattern must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/ReactivePubSubCommandsImpl.java","lineNumber":119,"sourceCode":"\n    @Override\n    public Uni<ReactiveRedisSubscriber> subscribeToPattern(String pattern, Consumer<V> onMessage, Runnable onEnd,\n            Consumer<Throwable> onException) {\n        return subscribeToPatterns(List.of(pattern), onMessage, onEnd, onException);\n    }\n\n    @Override\n    public Uni<ReactiveRedisSubscriber> subscribeToPattern(String pattern, BiConsumer<String, V> onMessage, Runnable onEnd,\n            Consumer<Throwable> onException) {\n        return subscribeToPatterns(List.of(pattern), onMessage, onEnd, onException);\n    }\n\n    private void validatePatterns(List<String> patterns) {\n        notNullOrEmpty(patterns, \"patterns\");\n\n        for (String pattern : patterns) {\n            if (pattern == null) {\n                throw new IllegalArgumentException(\"Pattern must not be null\");\n            }\n            if (pattern.isBlank()) {\n                throw new IllegalArgumentException(\"Pattern cannot be blank\");\n            }\n        }\n    }\n\n    @Override\n    public Uni<ReactiveRedisSubscriber> subscribeToPatterns(List<String> patterns, Consumer<V> onMessage, Runnable onEnd,\n            Consumer<Throwable> onException) {\n        nonNull(onMessage, \"onMessage\");\n        validatePatterns(patterns);\n\n        return RedisConnections.withNewLongLivedConnection(client, conn -> {\n            RedisAPI api = RedisAPI.api(conn);\n            ReactiveRedisPatternSubscriberImpl subscriber = new ReactiveRedisPatternSubscriberImpl(conn, api, patterns,\n                    (channel, value) -> onMessage.accept(value), onEnd, onException);\n            return subscriber.subscribe()","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/ReactivePubSubCommandsImpl.java#L101-L137","documentation":"validatePatterns() pre-checks the list passed to pattern-based pub/sub subscriptions. A null element inside the patterns list is invalid because Redis PSUBSCRIBE requires literal glob patterns; the method throws IllegalArgumentException before any network call is made.","triggerScenarios":"Calling subscribeToPatterns(...) with a List<String> that contains a null element (list itself is checked by notNullOrEmpty first).","commonSituations":"Building the pattern list dynamically from config or user input where a missing entry becomes null; mapping nullable config values into the subscription list.","solutions":["Filter or reject null entries before subscribing: patterns.stream().filter(Objects::nonNull).toList().","Validate subscription patterns at configuration/initialization time.","Use explicit defaults (e.g. \"*\") when a pattern is absent."],"exampleFix":"// before\nsubscriber = pubsub.subscribeToPatterns(patterns, onMessage);\n\n// after\nList<String> safe = patterns.stream().filter(p -> p != null && !p.isBlank()).toList();\nsubscriber = pubsub.subscribeToPatterns(safe, onMessage);","handlingStrategy":"validation","validationCode":"if (patterns == null || patterns.stream().anyMatch(Objects::isNull)) {\n    throw new IllegalArgumentException(\"patterns must not contain null elements\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    pubsub.subscribeToPatterns(patterns, onMessage);\n} catch (IllegalArgumentException e) {\n    // sanitize input and retry\n}","preventionTips":["Sanitize subscription pattern lists built from dynamic input.","Use Optional/config defaults instead of nullable strings for patterns.","Unit-test pattern assembly code paths."],"tags":["redis","quarkus","pubsub","argument-validation"],"backgroundTag":"invalid-argument-null","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}