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

  1. Use one of the exact words, case-insensitive: "off", "failed", or "all"
  2. Fix the property/config value feeding fromString and re-run
  3. 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

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


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)