karatelabs/karate · error
[callSingle] caching exception for
Error message
[callSingle] caching exception for: {} - {} What it means
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.
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.
Example fix
// before
def result = callSingle('classpath:setup/token.feature') // feature itself failing
// after
// fix setup/token.feature first, then restart the test JVM (cached exception is in-memory only) Defensive patterns
Strategy: retry
Validate before calling
// pre-check the feature resolves before callSingle
boolean exists = getClass().getResource(path) != null;
if (!exists) throw new RuntimeException("callSingle feature not found: " + path); Try / catch
try { result = callSingle(path, arg); } catch (Exception e) { /* exception is cached in-memory; restart JVM after fixing the feature */ throw e; } Prevention
- 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.
When it happens
Trigger: executeCallSingleInternal throws for a callSingle(path, arg) call — the feature itself failed, could not be found, or its setup threw — during ScenarioRuntime callSingle execution.
Common situations: 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.
Related errors
- callSingle failed
- karate.callSingle() is not available in this context
- karate.callSingle() requires at least one argument (path)
- karate.setupOnce() requires a feature context
- karate.callonce() requires a feature context
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/e9a5ae3365284605.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java:767
} else {
logger.info("[callSingle] disk cache stale: {} (modified {}ms ago, threshold {}min)",
cacheFile, System.currentTimeMillis() - lastModified, cacheMinutes);
}
} else {
logger.debug("[callSingle] disk cache miss, will create: {}", cacheFile);
}
}
// Execute if not found in disk cache
if (result == null) {
logger.info("[callSingle] >> executing: {}", path);
long startExec = System.currentTimeMillis();
try {
result = executeCallSingleInternal(path, arg);
} catch (Exception e) {
// Cache the exception so subsequent calls also fail fast
logger.warn("[callSingle] caching exception for: {} - {}", path, e.getMessage());
cache.put(path, new CallSingleException(e));
throw e;
}
long execTime = System.currentTimeMillis() - startExec;
logger.info("[callSingle] << executed in {}ms: {}", execTime, path);
// Write to disk cache if configured and result is JSON-like
if (cacheMinutes > 0 && cacheFile != null) {
String notJsonLike = Json.isMapOrList(result) ? findNonJsonValue(result, "$") : "the result itself";
if (notJsonLike == null) {
try {
cacheFile.getParentFile().mkdirs();
String json = StringUtils.formatJson(result, false, false, false);
Files.writeString(cacheFile.toPath(), json);
logger.info("[callSingle] disk cache write: {}", cacheFile);
} catch (IOException e) {
logger.warn("[callSingle] disk cache write failed: {} - {}", cacheFile, e.getMessage());View on GitHub (pinned to a22eb90246)