quarkusio/quarkus · error · IllegalArgumentException
The timestamp must be positive
Error message
The timestamp must be positive
What it means
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.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/timeseries/RangeArgs.java:55
public RangeArgs latest() {
this.latest = true;
return this;
}
/**
* Filters samples by a list of specific timestamps.
* A sample passes the filter if its exact timestamp is specified and falls within [fromTimestamp, toTimestamp].
*
* @param timestamps the timestamps
* @return the current {@code MRangeArgs}
*/
public RangeArgs filterByTimestamp(long... timestamps) {
if (filterByTimestamps == null) {
filterByTimestamps = new ArrayList<>(timestamps.length);
}
for (long timestamp : timestamps) {
if (timestamp < 0) {
throw new IllegalArgumentException("The timestamp must be positive");
}
filterByTimestamps.add(timestamp);
}
return this;
}
/**
* Filters samples by minimum and maximum values.
*
* @param min the min value of the sample
* @param max the max value of the sample
* @return the current {@code MRangeArgs}
*/
public RangeArgs filterByValue(double min, double max) {
this.filterByValue = true;
this.min = min;
this.max = max;
View on GitHub (pinned to e1c734241f)
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
Example fix
// before args.filterByTimestamp(-1, 100, 200); // -1 sentinel // after args.filterByTimestamp(100, 200);
Defensive patterns
Strategy: validation
Validate before calling
if (Arrays.stream(timestamps).anyMatch(t -> t < 0)) {
throw new IllegalArgumentException("all timestamps must be >= 0");
}
args.filterByTimestamp(timestamps); Type guard
boolean validTimestamps(long... ts) {
return Arrays.stream(ts).noneMatch(t -> t < 0);
} Try / catch
try {
args.filterByTimestamp(timestamps);
} catch (IllegalArgumentException e) {
timestamps = Arrays.stream(timestamps).filter(t -> t >= 0).toArray();
args.filterByTimestamp(timestamps);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Using -1 to mean 'not set'; date arithmetic producing negative epoch values; importing legacy data with negative timestamp columns.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The timestamp must be positive
- Cannot use `WITHLABELS` and `SELECTED_LABELS together
- Cannot combine `WITHLABELS` and `SELECTED_LABELS`
- `timeout` must not be `null`
- `timestamp` must not be `null`
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/a54c85e7eafd0357.
Report an issue: GitHub.