{"record":{"id":"a54c85e7eafd0357","repo":"quarkusio/quarkus","slug":"the-timestamp-must-be-positive-a54c85","errorCode":null,"errorMessage":"The timestamp must be positive","messagePattern":"The timestamp must be positive","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/timeseries/RangeArgs.java","lineNumber":55,"sourceCode":"    public RangeArgs latest() {\n        this.latest = true;\n        return this;\n    }\n\n    /**\n     * Filters samples by a list of specific timestamps.\n     * A sample passes the filter if its exact timestamp is specified and falls within [fromTimestamp, toTimestamp].\n     *\n     * @param timestamps the timestamps\n     * @return the current {@code MRangeArgs}\n     */\n    public RangeArgs filterByTimestamp(long... timestamps) {\n        if (filterByTimestamps == null) {\n            filterByTimestamps = new ArrayList<>(timestamps.length);\n        }\n        for (long timestamp : timestamps) {\n            if (timestamp < 0) {\n                throw new IllegalArgumentException(\"The timestamp must be positive\");\n            }\n            filterByTimestamps.add(timestamp);\n        }\n        return this;\n    }\n\n    /**\n     * Filters samples by minimum and maximum values.\n     *\n     * @param min the min value of the sample\n     * @param max the max value of the sample\n     * @return the current {@code MRangeArgs}\n     */\n    public RangeArgs filterByValue(double min, double max) {\n        this.filterByValue = true;\n        this.min = min;\n        this.max = max;\n","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/timeseries/RangeArgs.java#L37-L73","documentation":"RangeArgs.filterByTimestamp(long...) filters TS_RANGE samples by timestamps, which must be non-negative epoch values in RedisTimeSeries. Any negative timestamp is rejected with IllegalArgumentException. This is the single-key TS.RANGE analogue of the MRangeArgs check in error 1733.","triggerScenarios":"Calling rangeArgs.filterByTimestamp(...) with a negative long, e.g. -1 sentinels, arithmetic underflow from currentTimeMillis() minus an oversized duration, or negative values from upstream data.","commonSituations":"Using -1 to mean 'not set'; date arithmetic producing negative epoch values; importing legacy data with negative timestamp columns.","solutions":["Sanitize the array before the call: Arrays.stream(ts).filter(t -> t >= 0).toArray()","Clamp computed timestamps to >= 0 with Math.max(0, value)","Model 'unset' with Optional/omitting the call rather than negative sentinels"],"exampleFix":"// before\nargs.filterByTimestamp(-1, 100, 200); // -1 sentinel\n// after\nargs.filterByTimestamp(100, 200);","handlingStrategy":"validation","validationCode":"if (Arrays.stream(timestamps).anyMatch(t -> t < 0)) {\n    throw new IllegalArgumentException(\"all timestamps must be >= 0\");\n}\nargs.filterByTimestamp(timestamps);","typeGuard":"boolean validTimestamps(long... ts) {\n    return Arrays.stream(ts).noneMatch(t -> t < 0);\n}","tryCatchPattern":"try {\n    args.filterByTimestamp(timestamps);\n} catch (IllegalArgumentException e) {\n    timestamps = Arrays.stream(timestamps).filter(t -> t >= 0).toArray();\n    args.filterByTimestamp(timestamps);\n}","preventionTips":["Guard against arithmetic underflow when computing 'now minus duration'","Represent missing timestamps by omitting the filter call, not negative values","Validate imported/legacy timestamp data for negative values"],"tags":["java","redis","redis-timeseries","validation"],"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"}