{"record":{"id":"dcf35cc7c656ef5f","repo":"karatelabs/karate","slug":"missing-argument-for-paramint","errorCode":null,"errorMessage":"missing argument for paramInt()","messagePattern":"missing argument for paramInt\\(\\)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/http/HttpRequest.java","lineNumber":564,"sourceCode":"    }\n\n    private JavaInvokable paramValues() {\n        return args -> {\n            if (args.length > 0) {\n                return getParamValues(args[0] + \"\");\n            } else {\n                throw new RuntimeException(\"missing argument for paramValues()\");\n            }\n        };\n    }\n\n    private JavaInvokable paramInt() {\n        return args -> {\n            if (args.length > 0) {\n                String val = getParam(args[0] + \"\");\n                return val == null ? null : Integer.parseInt(val);\n            } else {\n                throw new RuntimeException(\"missing argument for paramInt()\");\n            }\n        };\n    }\n\n    private JavaInvokable paramJson() {\n        return args -> {\n            if (args.length > 0) {\n                String val = getParam(args[0] + \"\");\n                if (val == null) {\n                    return null;\n                }\n                try {\n                    return Json.of(val).value();\n                } catch (Exception e) {\n                    return val; // return raw string if not valid JSON\n                }\n            } else {\n                throw new RuntimeException(\"missing argument for paramJson()\");","sourceCodeStart":546,"sourceCodeEnd":582,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/http/HttpRequest.java#L546-L582","documentation":"Generic arity guard inside HttpRequest's private paramInt() invokable: it fires when paramInt() is invoked with zero arguments. The input at fault is the missing parameter name; with an argument it parses the named request parameter as an Integer (returning null when absent), so the no-arg call leaves nothing to parse and throws this sentinel RuntimeException.","triggerScenarios":"Calling request.paramInt() with no arguments instead of request.paramInt('page').","commonSituations":"Omitted argument in scripts, template-generated expressions where the name variable was empty, confusion with typed getter signatures.","solutions":["Pass the parameter name: request.paramInt('page')","Verify the name variable is non-empty before invocation","Note: if the parameter exists but is non-numeric, a NumberFormatException will surface instead — validate the value if needed"],"exampleFix":"// before\nvar n = request.paramInt();\n// after\nvar n = request.paramInt('page');","handlingStrategy":"type-guard","validationCode":"if (name == null || name.isEmpty()) throw new IllegalArgumentException(\"param name required\");","typeGuard":"function requireArg(name, args) { if (args == null || args.length === 0) throw new Error('missing argument for paramInt()'); return name; }","tryCatchPattern":"try { var n = request.paramInt('page'); } catch (RuntimeException e) { /* fix call site or handle non-numeric value */ }","preventionTips":["Always pass the parameter name to paramInt()","Validate interpolated name variables before use","Also validate the parameter value is numeric — parseInt will throw NumberFormatException otherwise"],"tags":["http","arguments","api-misuse"],"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-16T19:17:19.609Z"}