{"record":{"id":"6790b1b71f464cff","repo":"karatelabs/karate","slug":"logreplaylimit-must-be-at-least-1-was-use-logreplay-failed","errorCode":null,"errorMessage":"logReplayLimit must be at least 1, was:  (use logReplay(FAILED) to replay only the failing feature)","messagePattern":"logReplayLimit must be at least 1, was:  \\(use logReplay\\(FAILED\\) to replay only the failing feature\\)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"karate-gatling/src/main/java/io/karatelabs/gatling/KarateProtocolBuilder.java","lineNumber":152,"sourceCode":"        }\n        return this;\n    }\n\n    /**\n     * How many already-passed feature logs to retain per virtual user in\n     * {@link KarateLogReplay#ALL} mode, defaulting to {@value LogReplayer#DEFAULT_LIMIT}. This text\n     * is held in memory for every virtual user until it is replayed or dropped, so raise it with\n     * the run's concurrency in mind. Once a replay happens the retained logs are cleared, which is\n     * what keeps the window to the current iteration in the common case — Gatling gives an action\n     * no iteration boundary to hook, so the guarantee is \"the last N Karate calls for this user\".\n     *\n     * @return this builder for chaining\n     */\n    public KarateProtocolBuilder logReplayLimit(int limit) {\n        if (limit < 1) {\n            // zero would retain nothing AND report nothing dropped, quietly turning ALL into\n            // FAILED — which is a mode you can just ask for\n            throw new IllegalArgumentException(\"logReplayLimit must be at least 1, was: \" + limit\n                    + \" (use logReplay(FAILED) to replay only the failing feature)\");\n        }\n        this.logReplayLimit = limit;\n        return this;\n    }\n\n    /**\n     * Share one connection pool across the whole simulation, instead of opening a connection per\n     * iteration.\n     *\n     * <p>Karate builds an HTTP client per scenario execution, so under Gatling it reconnects every\n     * iteration where plain Gatling reuses a connection per virtual user. On a two-host bench that\n     * was 4000 distinct client ports against 8, and collapsing it was worth about 24% of Karate's\n     * per-iteration overhead against a plaintext endpoint on the same network — more against a\n     * public TLS endpoint, where the avoided handshake costs two round trips and asymmetric crypto.\n     *\n     * <p><b>Read {@link PooledHttpClientFactory} before turning this on.</b> A pooled client cannot\n     * honour {@code configure ssl} set inside a scenario and ignores it silently, and NTLM does not","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-gatling/src/main/java/io/karatelabs/gatling/KarateProtocolBuilder.java#L134-L170","documentation":"KarateProtocolBuilder.logReplayLimit(int) caps how many log entries are replayed per request in the Gatling report. A value below 1 is rejected because zero would retain nothing while silently turning the ALL replay mode into FAILED-like behavior; the message also hints at using logReplay(FAILED) for the common intent.","triggerScenarios":"Calling logReplayLimit(0) or logReplayLimit(negative), usually from an integer parsed from config where the property was missing/mistyped (e.g. Integer.parseInt(\"\") handled elsewhere, or default 0).","commonSituations":"Config placeholder defaulting to 0; developer wanting 'unlimited' and guessing 0 means unlimited; migrating from a boolean-style setting.","solutions":["Pass a positive integer, e.g. logReplayLimit(100)","If the goal is 'only failing requests', call logReplay(FAILED) instead of limit 0","If the goal is everything, keep the default / logReplay(ALL) and a large limit"],"exampleFix":"// before\nprotocol.logReplayLimit(Integer.getInteger(\"replay.limit\", 0));\n// after\nprotocol.logReplayLimit(Integer.getInteger(\"replay.limit\", 100));","handlingStrategy":"validation","validationCode":"if (limit < 1) { throw new IllegalArgumentException(\"logReplayLimit must be >= 1\"); }","typeGuard":null,"tryCatchPattern":"try {\n  protocol.logReplayLimit(limit);\n} catch (IllegalArgumentException e) {\n  protocol.logReplayLimit(100);\n}","preventionTips":["Never use 0 to mean 'unlimited' — there is no unlimited; use a large positive value","If you want only failures replayed, use logReplay(FAILED), not limit 0","Give config properties positive non-zero defaults"],"tags":["gatling","karate","configuration","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}