{"record":{"id":"32e4dac0ef5911df","repo":"quarkusio/quarkus","slug":"radius-must-be-positive-32e4da","errorCode":null,"errorMessage":"`radius` must be positive","messagePattern":"`radius` must be positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchStoreArgs.java","lineNumber":68,"sourceCode":"     * @param latitude the latitude\n     * @return the current {@code GeoSearchStoreArgs}\n     */\n    private GeoSearchStoreArgs<V> fromCoordinate(double longitude, double latitude) {\n        this.longitude = longitude;\n        this.latitude = latitude;\n        return this;\n    }\n\n    /**\n     * Search inside circular area according to given {@code radius}.\n     *\n     * @param radius the radius value\n     * @param unit the unit\n     * @return the current {@code GeoSearchStoreArgs}\n     **/\n    public GeoSearchStoreArgs<V> byRadius(double radius, GeoUnit unit) {\n        if (radius < 0) {\n            throw new IllegalArgumentException(\"`radius` must be positive\");\n        }\n        if (unit == null) {\n            throw new IllegalArgumentException(\"`unit` cannot be `null`\");\n        }\n        this.radius = radius;\n        this.unit = unit;\n        return this;\n    }\n\n    /**\n     * Search inside circular area according to given {@code radius}.\n     *\n     * @param width the width of the box\n     * @param height the height of the box\n     * @param unit the unit\n     * @return the current {@code GeoSearchStoreArgs}\n     **/\n    public GeoSearchStoreArgs<V> byBox(double width, double height, GeoUnit unit) {","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/geo/GeoSearchStoreArgs.java#L50-L86","documentation":"GeoSearchStoreArgs.byRadius(radius, unit) rejects negative radius values with IllegalArgumentException ('positive' here means >= 0 in the implementation, since the check is radius < 0). Redis GEOSEARCHSTORE BYRADIUS requires a non-negative numeric radius; a negative value is invalid input.","triggerScenarios":"Calling byRadius with a negative double, e.g. byRadius(-5, GeoUnit.km), usually from a computed/unsanitized value (user input, subtraction that went negative, unparsed config).","commonSituations":"Search-radius computed as (a - b) that can go negative; user-supplied radius not validated; unit-conversion arithmetic errors.","solutions":["Ensure the radius is >= 0 before calling byRadius (e.g. Math.max(0, radius))","Validate user/config input at the boundary and reject negative radii with a friendly message","Check the computation that produces the radius for sign errors"],"exampleFix":"// before\ndouble radius = maxKm - usedKm; // can be negative\nargs.byRadius(radius, GeoUnit.km);\n// after\ndouble radius = Math.max(0, maxKm - usedKm);\nargs.byRadius(radius, GeoUnit.km);","handlingStrategy":"validation","validationCode":"if (radius < 0) {\n    throw new IllegalArgumentException(\"radius must be >= 0, got \" + radius);\n}\nargs.byRadius(radius, unit);","typeGuard":"boolean isValidRadius(double radius) { return !Double.isNaN(radius) && radius >= 0; }","tryCatchPattern":"try {\n    args.byRadius(radius, unit);\n} catch (IllegalArgumentException e) {\n    log.error(\"Invalid radius {}: {}\", radius, e.getMessage());\n    throw new BadRequestException(\"Radius must be non-negative\");\n}","preventionTips":["Clamp computed radii with Math.max(0, value)","Validate user-supplied radii at the REST/config boundary","Add tests for negative and NaN inputs"],"tags":["redis","argument-validation","geo-commands","numeric-range"],"backgroundTag":"invalid-argument-value","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"}