karatelabs/karate · error · RuntimeException

karate.call() requires at least one argument (feature path)

Error message

karate.call() requires at least one argument (feature path)

What it means

karate.call() requires a feature (or script) path as its first argument; with zero arguments there is nothing to call. The runtime check has already passed, so this fires when a runtime exists but no arguments were supplied to the JavaInvokable.

Solutions

  1. Pass the feature path: karate.call('classpath:path/to/feature.feature') or karate.call(path, arg).
  2. Use the explicit-scope signature when needed: karate.call(true, path) / karate.call(false, path, arg).
  3. Guard dynamic call sites: only invoke karate.call when the path string is non-empty.

Example fix

// before
karate.call();
// after
karate.call('classpath:helpers/utils.feature', { foo: 'bar' });
Defensive patterns

Strategy: validation

Validate before calling

if (typeof path !== 'string' || path.length === 0) {
  throw new Error('karate.call requires a feature path');
}
karate.call(path, arg);

Type guard

function isFeaturePath(p) { return typeof p === 'string' && p.trim().length > 0 && p.includes('.feature'); }

Try / catch

var result;
try {
  result = karate.call(path, arg);
} catch (e) {
  if (String(e.message).includes('requires at least one argument')) {
    throw new Error('feature path was undefined/empty when calling karate.call: ' + path);
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling karate.call() with an empty argument list while a scenario runtime is active — e.g. karate.call() directly, or karate.call(...args) where args resolves to [].

Common situations: Dynamic call-site construction where the feature path variable is undefined or the arguments array is empty; typos dropping the path; refactors that removed a default path.

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/cedf2d1a74d45cb1. Report an issue: GitHub.

Appendix: source

Thrown at karate-core/src/main/java/io/karatelabs/core/KarateJs.java:693

                }
                if (rt == null) {
                    throw new RuntimeException("karate.match(String) is not available in this context");
                }
                String expression = args[0].toString();
                Result result = rt.getExecutor().evalMatchString(expression, null);
                return result.toMap();
            }
        };
    }

    private JavaInvokable call() {
        return args -> {
            ScenarioRuntime rt = getRuntime();
            if (rt == null) {
                throw new RuntimeException("karate.call() is not available in this context");
            }
            if (args.length == 0) {
                throw new RuntimeException("karate.call() requires at least one argument (feature path)");
            }
            // V1 compatible signatures:
            // call(path) - isolated scope
            // call(path, arg) - isolated scope with arg
            // call(sharedScope, path) - explicit scope
            // call(sharedScope, path, arg) - explicit scope with arg
            boolean sharedScope = false;
            String path;
            Object arg;
            if (args[0] instanceof Boolean) {
                sharedScope = (Boolean) args[0];
                if (args.length < 2) {
                    throw new RuntimeException("karate.call() with sharedScope requires a feature path");
                }
                path = args[1].toString();
                arg = args.length > 2 ? args[2] : null;
            } else {
                path = args[0].toString();

View on GitHub (pinned to a22eb90246)