karatelabs/karate · error · IllegalArgumentException
pauseMillis cannot be negative
Error message
pauseMillis cannot be negative
What it means
Record constructor invariant for MethodPause: a pause duration only makes sense as zero or positive milliseconds. Fires when a negative pauseMillis is passed to the compact constructor; pass 0 or a positive value.
Solutions
- Use 0 or a positive value for pauseMillis
- Clamp computed values: Math.max(0, computedPause)
- Fix the min/max order in any randomization code (e.g. use between(min, max) with min <= max)
Example fix
// before
long pause = target - current; // can be negative
new MethodPause("GET", (int) pause);
// after
long pause = Math.max(0, target - current);
new MethodPause("GET", (int) pause); Defensive patterns
Strategy: validation
Validate before calling
if (pauseMillis < 0) throw new IllegalArgumentException("pauseMillis must be >= 0");
new MethodPause(method, pauseMillis); Try / catch
try { return new MethodPause(method, pauseMillis); } catch (IllegalArgumentException e) { log.warn("rejecting negative pause {}: using 0", pauseMillis); return new MethodPause(method, 0); } Prevention
- Clamp computed pauses with Math.max(0, value)
- Double-check min/max argument order in randomization helpers
- Never hand-enter negative durations in pause config
When it happens
Trigger: new MethodPause("GET", -100) — usually from arithmetic like (target - current) that went negative, or a config value entered as a negative number, or subtracting timestamps in the wrong order.
Common situations: Computing randomized pauses where a max below the min yields a negative delta; mis-typed config values in pause tuning; timezone/clock-order bugs when deriving pauses from measured times.
Related errors
- method cannot be null or blank
- pattern cannot be null or blank
- cannot replace root path $
- configure logging.mask: unknown key
- could not build the pooled client's SSL context
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/8532085aadf34b4e.
Report an issue: GitHub.
Appendix: source
Thrown at karate-gatling/src/main/java/io/karatelabs/gatling/MethodPause.java:40
* THE SOFTWARE.
*/
package io.karatelabs.gatling;
/**
* Represents a pause duration for a specific HTTP method.
* Used with URI patterns to define method-specific pauses after requests.
*
* @param method the HTTP method (GET, POST, etc.)
* @param pauseMillis the pause duration in milliseconds
*/
public record MethodPause(String method, int pauseMillis) {
public MethodPause {
if (method == null || method.isBlank()) {
throw new IllegalArgumentException("method cannot be null or blank");
}
if (pauseMillis < 0) {
throw new IllegalArgumentException("pauseMillis cannot be negative");
}
method = method.toUpperCase();
}
}
View on GitHub (pinned to a22eb90246)