karatelabs/karate · error · RuntimeException

missing argument for paramInt()

Error message

missing argument for paramInt()

What it means

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.

Solutions

  1. Pass the parameter name: request.paramInt('page')
  2. Verify the name variable is non-empty before invocation
  3. Note: if the parameter exists but is non-numeric, a NumberFormatException will surface instead — validate the value if needed

Example fix

// before
var n = request.paramInt();
// after
var n = request.paramInt('page');
Defensive patterns

Strategy: type-guard

Validate before calling

if (name == null || name.isEmpty()) throw new IllegalArgumentException("param name required");

Type guard

function requireArg(name, args) { if (args == null || args.length === 0) throw new Error('missing argument for paramInt()'); return name; }

Try / catch

try { var n = request.paramInt('page'); } catch (RuntimeException e) { /* fix call site or handle non-numeric value */ }

Prevention

When it happens

Trigger: Calling request.paramInt() with no arguments instead of request.paramInt('page').

Common situations: Omitted argument in scripts, template-generated expressions where the name variable was empty, confusion with typed getter signatures.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12). Data as JSON: /api/errors/dcf35cc7c656ef5f. Report an issue: GitHub.

Appendix: source

Thrown at karate-core/src/main/java/io/karatelabs/http/HttpRequest.java:564

    }

    private JavaInvokable paramValues() {
        return args -> {
            if (args.length > 0) {
                return getParamValues(args[0] + "");
            } else {
                throw new RuntimeException("missing argument for paramValues()");
            }
        };
    }

    private JavaInvokable paramInt() {
        return args -> {
            if (args.length > 0) {
                String val = getParam(args[0] + "");
                return val == null ? null : Integer.parseInt(val);
            } else {
                throw new RuntimeException("missing argument for paramInt()");
            }
        };
    }

    private JavaInvokable paramJson() {
        return args -> {
            if (args.length > 0) {
                String val = getParam(args[0] + "");
                if (val == null) {
                    return null;
                }
                try {
                    return Json.of(val).value();
                } catch (Exception e) {
                    return val; // return raw string if not valid JSON
                }
            } else {
                throw new RuntimeException("missing argument for paramJson()");

View on GitHub (pinned to a22eb90246)