{"record":{"id":"e9a5ae3365284605","repo":"karatelabs/karate","slug":"callsingle-caching-exception-for","errorCode":null,"errorMessage":"[callSingle] caching exception for: {} - {}","messagePattern":"\\[callSingle\\] caching exception for: (.+?) - (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java","lineNumber":767,"sourceCode":"                    } else {\n                        logger.info(\"[callSingle] disk cache stale: {} (modified {}ms ago, threshold {}min)\",\n                                cacheFile, System.currentTimeMillis() - lastModified, cacheMinutes);\n                    }\n                } else {\n                    logger.debug(\"[callSingle] disk cache miss, will create: {}\", cacheFile);\n                }\n            }\n\n            // Execute if not found in disk cache\n            if (result == null) {\n                logger.info(\"[callSingle] >> executing: {}\", path);\n                long startExec = System.currentTimeMillis();\n\n                try {\n                    result = executeCallSingleInternal(path, arg);\n                } catch (Exception e) {\n                    // Cache the exception so subsequent calls also fail fast\n                    logger.warn(\"[callSingle] caching exception for: {} - {}\", path, e.getMessage());\n                    cache.put(path, new CallSingleException(e));\n                    throw e;\n                }\n\n                long execTime = System.currentTimeMillis() - startExec;\n                logger.info(\"[callSingle] << executed in {}ms: {}\", execTime, path);\n\n                // Write to disk cache if configured and result is JSON-like\n                if (cacheMinutes > 0 && cacheFile != null) {\n                    String notJsonLike = Json.isMapOrList(result) ? findNonJsonValue(result, \"$\") : \"the result itself\";\n                    if (notJsonLike == null) {\n                        try {\n                            cacheFile.getParentFile().mkdirs();\n                            String json = StringUtils.formatJson(result, false, false, false);\n                            Files.writeString(cacheFile.toPath(), json);\n                            logger.info(\"[callSingle] disk cache write: {}\", cacheFile);\n                        } catch (IOException e) {\n                            logger.warn(\"[callSingle] disk cache write failed: {} - {}\", cacheFile, e.getMessage());","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java#L749-L785","documentation":"A callSingle feature invocation failed. Karate caches the exception (CallSingleException) in the in-memory cache so all subsequent callSingle calls for the same path fail fast with the same error instead of re-executing, and logs this warning before rethrowing the original exception.","triggerScenarios":"executeCallSingleInternal throws for a callSingle(path, arg) call — the feature itself failed, could not be found, or its setup threw — during ScenarioRuntime callSingle execution.","commonSituations":"The called feature has an assertion or HTTP failure on first run; wrong feature path so it can't load; exception in the feature's Background; callers repeatedly invoking callSingle and expecting retry semantics.","solutions":["Fix the underlying exception shown after this warning — that is the real failure; the message here only records it.","Restart the JVM/suite after fixing: the exception stays cached in memory for the process lifetime.","Verify the callSingle path resolves to an existing feature on the classpath/file system.","If retry behavior is desired, don't rely on callSingle — it intentionally fail-fasts once cached."],"exampleFix":"// before\ndef result = callSingle('classpath:setup/token.feature') // feature itself failing\n// after\n// fix setup/token.feature first, then restart the test JVM (cached exception is in-memory only)","handlingStrategy":"retry","validationCode":"// pre-check the feature resolves before callSingle\nboolean exists = getClass().getResource(path) != null;\nif (!exists) throw new RuntimeException(\"callSingle feature not found: \" + path);","typeGuard":null,"tryCatchPattern":"try { result = callSingle(path, arg); } catch (Exception e) { /* exception is cached in-memory; restart JVM after fixing the feature */ throw e; }","preventionTips":["Fix the root exception before re-running; the failure is cached for process lifetime.","Validate callSingle paths resolve on the classpath.","Ensure called features pass in isolation before wiring into callSingle."],"tags":["callsingle","caching","fail-fast"],"backgroundTag":"cached-execution-failure","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"}