{"record":{"id":"582ae9bbcc13fb74","repo":"quarkusio/quarkus","slug":"any-can-only-be-used-if-count-is-also-set-582ae9","errorCode":null,"errorMessage":"ANY can only be used if COUNT is also set","messagePattern":"ANY can only be used if COUNT is also set","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoRadiusStoreArgs.java","lineNumber":133,"sourceCode":"    }\n\n    /**\n     * Store the items in a sorted set populated with their distance from the center as a floating point number, in the\n     * same unit specified in the radius.\n     *\n     * @param storeDistKey the storeDistKey value\n     * @return the current {@code GeoRadiusStoreArgs}\n     **/\n    public GeoRadiusStoreArgs<K> storeDistKey(K storeDistKey) {\n        this.storeDistKey = storeDistKey;\n        return this;\n    }\n\n    @Override\n    public List<Object> toArgs(Codec codec) {\n        // Validation\n        if (any && count == -1) {\n            throw new IllegalArgumentException(\"ANY can only be used if COUNT is also set\");\n        }\n        if (storeDistKey == null && storeKey == null) {\n            throw new IllegalArgumentException(\"At least `STORE` or `STOREDIST` must be set\");\n        }\n\n        List<Object> list = new ArrayList<>();\n        if (withDistance) {\n            list.add(\"WITHDIST\");\n        }\n        if (withCoordinates) {\n            list.add(\"WITHCOORD\");\n        }\n        if (withHash) {\n            list.add(\"WITHHASH\");\n        }\n\n        if (count > 0) {\n            list.add(\"COUNT\");","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoRadiusStoreArgs.java#L115-L151","documentation":"GEOSEARCH/GEOPOS-style radius commands in the Quarkus Redis datasource accept an ANY modifier, which tells Redis not to sort results and return them as soon as enough are found. ANY is only meaningful together with the COUNT option, so GeoRadiusStoreArgs.toArgs validates the combination before building the command and throws IllegalArgumentException if `any` is set while no count was configured. This is a client-side guard that prevents sending an invalid command to Redis.","triggerScenarios":"Calling gposition/georadius args construction where setAny(true) (or the fluent any() variant) was invoked but setCount(...) was never called, then passing the GeoRadiusStoreArgs to a geo command that calls toArgs(codec).","commonSituations":"Developers copy example code using ANY for performance and forget the COUNT option; refactoring removes a count() call while leaving any(); builders reused across calls where one call set any but count was reset.","solutions":["Add a COUNT option, e.g. args.setCount(10), whenever ANY is used","Remove the ANY flag if unbounded results with sorting are acceptable","Guard the args construction so any is only set when a count value is also configured"],"exampleFix":"// before\nGeoRadiusStoreArgs<String> args = GeoRadiusStoreArgs.fromCoordinates(...)\n    .any();\n// after\nGeoRadiusStoreArgs<String> args = GeoRadiusStoreArgs.fromCoordinates(...)\n    .count(10)\n    .any();","handlingStrategy":"validation","validationCode":"if (args.isAny() && args.getCount() == -1) { throw new IllegalStateException(\"ANY requires COUNT\"); }","typeGuard":null,"tryCatchPattern":"try { geo.geoSearchStore(...); } catch (IllegalArgumentException e) { log.error(\"Invalid geo args: \" + e.getMessage()); }","preventionTips":["Always pair any() with an explicit count(n)","Centralize geo args construction in a helper method that enforces the invariant","Add unit tests asserting the args combination you ship"],"tags":["redis","geo","illegal-argument","argument-validation"],"backgroundTag":"invalid-argument-combination","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}