{"record":{"id":"8376eaed48b6238a","repo":"karatelabs/karate","slug":"missing-argument-for-param","errorCode":null,"errorMessage":"missing argument for param()","messagePattern":"missing argument for param\\(\\)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/http/HttpRequest.java","lineNumber":543,"sourceCode":"        if (headers != null) {\n            headers.forEach((name, values) -> {\n                if (values != null && !values.isEmpty()) {\n                    builder.header(name, values);\n                }\n            });\n        }\n        if (body != null) {\n            builder.body(getBodyConverted());\n        }\n        return builder;\n    }\n\n    private JavaInvokable param() {\n        return args -> {\n            if (args.length > 0) {\n                return getParam(args[0] + \"\");\n            } else {\n                throw new RuntimeException(\"missing argument for param()\");\n            }\n        };\n    }\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] + \"\");","sourceCodeStart":525,"sourceCodeEnd":561,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/http/HttpRequest.java#L525-L561","documentation":"Generic arity guard inside HttpRequest's private param() invokable: it fires when the dynamic member-call invokes request.param() with zero arguments at runtime. The input at fault is the missing name argument (the query/path parameter key to look up). Any scripted call to param() without a string name — typically from JS-like request chaining — triggers this sentinel RuntimeException.","triggerScenarios":"Invoking request.param() with zero arguments in a script/expression, e.g. request.param() instead of request.param('name').","commonSituations":"Copy-paste deleting the argument, dynamic generation of the call where the variable holding the param name was empty/null and dropped, typo leaving the parenthesis empty.","solutions":["Pass the parameter name: request.param('id')","If the name comes from a variable, verify the variable is non-null/non-empty before the call","Check generated/configured script strings for an elided argument"],"exampleFix":"// before\nvar v = request.param();\n// after\nvar v = request.param('userId');","handlingStrategy":"type-guard","validationCode":"// ensure the argument is present and non-empty before the call\nif (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 param()'); return name; }","tryCatchPattern":"try { var v = request.param('id'); } catch (RuntimeException e) { /* missing-argument misuse; fix the call site */ }","preventionTips":["Always pass the parameter name to param()","Validate name-bearing variables are non-empty before interpolation into scripts","Review auto-generated or templated script strings for dropped arguments"],"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"}