karatelabs/karate · error · IllegalArgumentException
invalid log replay mode: '', expected one of: off, failed…
Error message
invalid log replay mode: '', expected one of: off, failed, all
What it means
KarateLogReplay.fromString(value) parses a log replay mode string into the OFF/FAILED/ALL enum. Any string that does not case-insensitively match one of off, failed, all throws IllegalArgumentException naming the offending value and the valid options. Null maps to OFF rather than throwing.
Solutions
- Use one of the exact words, case-insensitive: "off", "failed", or "all"
- Fix the property/config value feeding fromString and re-run
- Default is OFF — remove the setting entirely if you do not want replay
Example fix
// before
KarateLogReplay mode = KarateLogReplay.fromString(System.getProperty("replay", "on"));
// after
KarateLogReplay mode = KarateLogReplay.fromString(System.getProperty("replay", "failed")); Defensive patterns
Strategy: validation
Validate before calling
String v = System.getProperty("replay", "off").trim().toLowerCase();
if (!v.equals("off") && !v.equals("failed") && !v.equals("all")) { throw new IllegalArgumentException("replay mode must be off|failed|all"); } Try / catch
try {
mode = KarateLogReplay.fromString(raw);
} catch (IllegalArgumentException e) {
mode = KarateLogReplay.OFF; // or rethrow with context
} Prevention
- Only use the literals off/failed/all (case-insensitive) in config
- Rely on null -> OFF default instead of passing empty strings
- Document valid values next to the config key
When it happens
Trigger: Calling KarateLogReplay.fromString with a mistyped or unsupported mode, e.g. fromString(""), fromString("on"), fromString("faild"), or from config/properties holding a wrong value.
Common situations: Setting karate logReplay mode via system property with a typo; assuming an 'on'/'off' boolean style works; trailing whitespace or quotes from YAML/properties parsing (trim is applied, but invalid words still fail).
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- invalid log replay level: '', expected one of: trace…
- feature path is required
- logReplayLimit must be at least 1, was: (use…
- pool sizes must be at least 1, got maxTotal= perRoute=
- key cannot be null or blank
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/67054bb82b7275b6.
Report an issue: GitHub.
Appendix: source
Thrown at karate-gatling/src/main/java/io/karatelabs/gatling/KarateLogReplay.java:63
* Replay the output of the features that already passed for this virtual user as well, oldest
* first, then the failing one. Retention is bounded by
* {@link KarateProtocolBuilder#logReplayLimit(int)} and is cleared after every replay.
*/
ALL;
/**
* Parse a mode by name, case-insensitively.
*
* @throws IllegalArgumentException if the name is not one of {@code off}, {@code failed}, {@code all}
*/
public static KarateLogReplay fromString(String value) {
if (value == null) {
return OFF;
}
try {
return valueOf(value.trim().toUpperCase(java.util.Locale.ROOT));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("invalid log replay mode: '" + value
+ "', expected one of: off, failed, all");
}
}
}
View on GitHub (pinned to a22eb90246)