karatelabs/karate · error · RuntimeException

called feature failed

Error message

called feature failed: <displayName>[ - <msg>]

What it means

After Karate runs a called feature (via 'call' of another .feature file), checkFeatureResult inspects the child FeatureResult; if it is marked failed, the failure is rethrown as a RuntimeException 'called feature failed: <name> - <message>' so the caller's step fails and propagates the nested error message.

Solutions

  1. Look at the '- <msg>' suffix and the full report: it names the failing step/line inside the called feature
  2. Run the called feature standalone to reproduce and debug it in isolation
  3. Fix the underlying failure (match mismatch, HTTP error, missing variable) in the called feature
  4. Check that variables expected by the called feature (via 'call ... {var: ...}') are actually passed and spelled correctly

Example fix

// before: called feature fails because var is undefined
call read('user.feature')
// after: pass required variables explicitly
call read('user.feature') { userId: '#(userId)' }
Defensive patterns

Strategy: try-catch

Validate before calling

// smoke-test the called feature standalone before wiring it into other features
// run: com.intuit.karate.Runner.path("classpath:helpers/setup.feature").parallel(1); and check exit status

Try / catch

try { karate.call("read('setup.feature')"); } catch (RuntimeException e) { if (e.getMessage().startsWith("called feature failed: ")) { log.error("nested failure: {}", e.getMessage()); } throw e; }

Prevention

When it happens

Trigger: A 'call' (or 'callonce') step invokes another feature and that feature has at least one failing step — assertion, match, HTTP status, or runtime error inside the called feature.

Common situations: Shared/setup features failing (missing test data, environment misconfig); matched values wrong in the called feature; timeouts on HTTP calls inside nested features; chain failures where the root cause is several layers deep.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at karate-core/src/main/java/io/karatelabs/core/StepExecutor.java:593

    List<Map<String, Object>> callFeatureLoop(Feature calledFeature, List<?> argList, String tagSelector, Set<Integer> lineFilters) {
        List<Map<String, Object>> results = new ArrayList<>();
        int loopIndex = 0;
        for (Object item : argList) {
            Map<String, Object> callArg = item instanceof Map ? (Map<String, Object>) item : null;
            // Always isolated scope for array loop
            Map<String, Object> vars = lastVars(runNestedFeature(calledFeature, callArg, false, tagSelector, lineFilters, loopIndex));
            if (vars != null) {
                results.add(vars);
            }
            loopIndex++;
        }
        return results;
    }

    void checkFeatureResult(FeatureResult featureResult) {
        if (featureResult.isFailed()) {
            String msg = featureResult.getFailureMessage();
            throw new RuntimeException("called feature failed: "
                    + featureResult.getDisplayName()
                    + (msg != null ? " - " + msg : ""));
        }
    }

    /**
     * Propagate results from a called feature back to the caller.
     * Handles both isolated scope (resultVar set) and shared scope (resultVar null).
     * For shared scope, also propagates config, cookies, and driver.
     */
    private void propagateFromCallee(ScenarioRuntime calleeRuntime, String resultVar) {
        if (calleeRuntime == null) {
            return;
        }
        if (resultVar != null) {
            // Isolated scope - store only the callee's own contribution (delta), not the
            // caller/config scope it inherited to read. See calleeResult.
            runtime.setVariable(resultVar, calleeResult(calleeRuntime));

View on GitHub (pinned to a22eb90246)