{"record":{"id":"69e70615893940e6","repo":"karatelabs/karate","slug":"expected-feature-or-featurecall-got","errorCode":null,"errorMessage":"expected Feature or FeatureCall, got: ","messagePattern":"expected Feature or FeatureCall, got: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/StepExecutor.java","lineNumber":2771,"sourceCode":"\n        Feature calledFeature;\n        String tagSelector = null;\n\n        if (featureObj instanceof FeatureCall) {\n            FeatureCall fc = (FeatureCall) featureObj;\n            if (fc.isSameFile()) {\n                calledFeature = fr != null ? fr.getFeature() : null;\n                if (calledFeature == null) {\n                    throw new RuntimeException(\"same-file tag call requires a feature context\");\n                }\n            } else {\n                calledFeature = fc.getFeature();\n            }\n            tagSelector = fc.getTagSelector();\n        } else if (featureObj instanceof Feature) {\n            calledFeature = (Feature) featureObj;\n        } else {\n            throw new RuntimeException(\"expected Feature or FeatureCall, got: \" + featureObj.getClass());\n        }\n\n        // Karate-expression eval handles inline JSON with embedded `#(...)`,\n        // arrays, variables, and bare JS uniformly.\n        Object argObj = argExpr == null ? null : evalKarateExpression(argExpr);\n\n        // Check if it's an array loop call\n        if (argObj instanceof List) {\n            List<Map<String, Object>> results = callFeatureLoop(calledFeature, (List<?>) argObj, tagSelector, null);\n            if (resultVar != null) {\n                runtime.setVariable(resultVar, results);\n            }\n            return;\n        }\n\n        // Single call with Map argument\n        Map<String, Object> callArg = null;\n        if (argObj instanceof Map) {","sourceCodeStart":2753,"sourceCodeEnd":2789,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/StepExecutor.java#L2753-L2789","documentation":"The call step executor expects its evaluated feature argument to be either a Feature object or a FeatureCall; anything else means the argument was not resolvable to a callable feature. The error includes the actual Java class found, making it a type-validation failure for the `call`/`callonce` keyword's argument.","triggerScenarios":"`call <expr>` where expr evaluates to a Map, String, List, or other object that is neither Feature nor FeatureCall — e.g. calling a JSON variable, or a variable set to the result of a previous call (call result object) rather than a feature reference.","commonSituations":"Mistyping a variable name so `call foo` picks up a data table or response payload instead of the feature; calling the result of another call (`* def r = call x ... * call r`) which is a result wrapper, not a FeatureCall; version migration where call results changed shape.","solutions":["Ensure the called variable is a feature path string passed through read(): `call read('other.feature')`","print the variable to see its actual type before the call","If you want call results, use `def res = call ...` and access res.response, do not call the result again","Assign the feature explicitly: def f = read('other.feature') then call f"],"exampleFix":"// before\n* def data = { a: 1 }\n* call data\n// after\n* call read('other.feature')","handlingStrategy":"type-guard","validationCode":"// karate\n* if (!(typeof featureRef == 'string') && !featureRef.read) karate.fail('not a feature ref')","typeGuard":"function isFeatureRef(v) { return typeof v === 'string' || (v && typeof v === 'object' && !!v.read); }","tryCatchPattern":null,"preventionTips":["Call features via call read('path.feature') to guarantee the right shape","Do not re-call results of previous calls","Keep feature-path variables separate from data variables by naming convention (e.g. featX)"],"tags":["call","type-mismatch","feature"],"backgroundTag":"type-mismatch","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"}