karatelabs/karate · info
[callSingle] disk cache skipped
Error message
[callSingle] disk cache skipped (not JSON-like at {}): {} What it means
callSingle completed and produced a result, but the result was deemed not JSON-like, so Karate skipped writing it to the disk cache. Only JSON-compatible objects can be persisted; results like Java objects, binaries, or other non-map/list values are cached in memory only. This warning indicates reduced caching effectiveness, not a failure.
Solutions
- Make the called feature return plain JSON: maps/lists of primitives instead of Java objects or binary data.
- Convert non-JSON results explicitly (e.g. karate.toJson or build the response as JSON in the feature).
- Accept the warning if the result is intentionally non-JSON — in-memory caching still applies.
- If the result should be JSON, log/inspect the returned value to find which member is not serializable.
Example fix
// before (called feature ends with)
* def result = javaConfig.buildObject()
// after
* def result = { token: javaConfig.getToken(), expiry: javaConfig.getExpiry() } Defensive patterns
Strategy: validation
Validate before calling
// verify the callSingle result is JSON-like before caching expectations if (!(result instanceof Map || result instanceof List)) skipDiskCache(result);
Type guard
boolean isJsonLike(Object o) { return o instanceof Map || o instanceof List || o instanceof String || o instanceof Number || o instanceof Boolean; } Prevention
- Design called features to return plain JSON structures.
- Convert Java/binary results to maps/lists before returning.
- Treat this warning as a hint to review what callSingle returns.
When it happens
Trigger: The callSingle result object fails the JSON-like check (notJsonLike non-zero) in ScenarioRuntime's disk-cache path, so the write branch is skipped.
Common situations: Called feature (or its configure/return) yields a Java object, byte array, or custom type; feature returns a variable set containing non-serializable values; version changes made the JSON-like detection stricter.
Understand the failure class
Background: "JSON serialization failed", "not JSON serializable", "Failed to serialize": why JSON marshaling errors happen and how to fix them — this error's family across 46 libraries.
Related errors
- [callSingle] disk cache read failed
- [callSingle] disk cache write failed
- <cached exception message>
- [callSingle] caching exception for
- callSingle failed
AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12).
Data as JSON: /api/errors/36f64b696d2eca02.
Report an issue: GitHub.
Appendix: source
Thrown at karate-core/src/main/java/io/karatelabs/core/ScenarioRuntime.java:788
}
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());
}
} else {
logger.warn("[callSingle] disk cache skipped (not JSON-like at {}): {}", notJsonLike, path);
}
}
}
// Cache in memory
cache.put(path, result);
logger.debug("[callSingle] memory cached: {}", path);
return StepUtils.deepCopy(result);
} finally {
lock.unlock();
}
}
/**
* Internal execution of callSingle - reads and evaluates the file.
* Supports:
* - ?suffix syntax for cache key differentiation (suffix is stripped for file read)View on GitHub (pinned to a22eb90246)