{"record":{"id":"ac5eae2b4d75097c","repo":"karatelabs/karate","slug":"method-cannot-be-null-or-blank","errorCode":null,"errorMessage":"method cannot be null or blank","messagePattern":"method cannot be null or blank","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"karate-gatling/src/main/java/io/karatelabs/gatling/MethodPause.java","lineNumber":37,"sourceCode":" * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n */\npackage io.karatelabs.gatling;\n\n/**\n * Represents a pause duration for a specific HTTP method.\n * Used with URI patterns to define method-specific pauses after requests.\n *\n * @param method the HTTP method (GET, POST, etc.)\n * @param pauseMillis the pause duration in milliseconds\n */\npublic record MethodPause(String method, int pauseMillis) {\n\n    public MethodPause {\n        if (method == null || method.isBlank()) {\n            throw new IllegalArgumentException(\"method cannot be null or blank\");\n        }\n        if (pauseMillis < 0) {\n            throw new IllegalArgumentException(\"pauseMillis cannot be negative\");\n        }\n        method = method.toUpperCase();\n    }\n\n}\n","sourceCodeStart":19,"sourceCodeEnd":46,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-gatling/src/main/java/io/karatelabs/gatling/MethodPause.java#L19-L46","documentation":"MethodPause is a compact-constructor record validating that the HTTP method is non-null, non-blank, and that the pause is non-negative, then normalizes the method to uppercase. A null/blank method throws IllegalArgumentException immediately at record creation.","triggerScenarios":"new MethodPause(null, 500) or new MethodPause(\" \", 500); typically when the method string comes from a parsed map key, split token, or optional config.","commonSituations":"Building method pauses from a config map where an entry has a missing/empty key; parsing strings like \":500\" where the method part is empty; case mistakes are fine (normalized) but blank input is not.","solutions":["Pass a concrete method name such as \"GET\", \"POST\", \"PUT\",\"DELETE\"","Trim/validate the method string before constructing the record","If parsing config, skip entries with blank methods instead of constructing them"],"exampleFix":"// before\nString m = parts.length > 0 ? parts[0] : \"\";\nnew MethodPause(m, pauseMs); // throws when m is blank\n// after\nif (parts.length > 0 && !parts[0].isBlank()) {\n    new MethodPause(parts[0], pauseMs);\n}","handlingStrategy":"validation","validationCode":"if (method == null || method.isBlank()) throw new IllegalArgumentException(\"method required\");\nnew MethodPause(method, pauseMillis);","typeGuard":null,"tryCatchPattern":"try { return new MethodPause(method, pauseMillis); } catch (IllegalArgumentException e) { throw new IllegalArgumentException(\"bad method pause for '\" + method + \"': \" + e.getMessage(), e); }","preventionTips":["Validate/skip blank entries when parsing pause config maps","Use an enum or constant set (GET/POST/...) for methods instead of free-form strings","Normalize case early — the record uppercases anyway"],"tags":["java","record","validation","http-method"],"backgroundTag":"missing-required-argument","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}