SonarSource/sonarqube · error · IllegalStateException
No cache entry found for key:
Error message
No cache entry found for key:
What it means
MemoryCache.get(K key) is a strict lookup: it delegates to getNullable(key) and, if nothing is stored under the key, throws IllegalStateException. The compute engine's analysis steps only call get() for keys they expect to have been populated earlier in the task, so an absent entry indicates a broken internal invariant (a step ran before the step that fills the cache, or the key derivation changed).
Source
Thrown at server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/util/cache/MemoryCache.java:55
public MemoryCache(CacheLoader<K, V> loader) {
this.loader = loader;
}
@CheckForNull
public V getNullable(K key) {
V value = map.get(key);
if (value == null && !map.containsKey(key)) {
value = loader.load(key);
map.put(key, value);
}
return value;
}
public V get(K key) {
V value = getNullable(key);
if (value == null) {
throw new IllegalStateException("No cache entry found for key: " + key);
}
return value;
}
/**
* Get values associated with keys. All the requested keys are included
* in the Map result. Value is null if the key is not found in cache.
*/
public Map<K, V> getAll(Iterable<K> keys) {
List<K> missingKeys = new ArrayList<>();
Map<K, V> result = new HashMap<>();
for (K key : keys) {
V value = map.get(key);
if (value == null && !map.containsKey(key)) {
missingKeys.add(key);
} else {
result.put(key, value);
}View on GitHub (pinned to 184c821202)
Solutions
- Check the compute engine step ordering: ensure the step that populates the cache (e.g. ComponentIssuesLoader / repository loaders) runs before the step calling get().
- Use getNullable(key) plus an explicit null check if absence is a legitimate case in your code path.
- Log/inspect the failing key and verify how it was derived versus how it was stored (same component ref/uuid).
- Verify the referenced entity actually exists in the project analysis data (component was not deleted mid-analysis).
Example fix
// before
Measure measure = measureRepository.getMetric(component, METRIC_KEY);
// after
Measure measure = measureRepository.getNullableMetric(component, METRIC_KEY);
if (measure == null) {
throw new IllegalStateException("Metric " + METRIC_KEY + " missing for " + component);
} Defensive patterns
Strategy: validation
Validate before calling
if (cache.getNullable(key) == null) { throw new IllegalStateException("cache miss for " + key); }
V value = cache.get(key); Try / catch
try {
value = cache.get(key);
} catch (IllegalStateException e) {
logger.warn("Cache miss: {}", e.getMessage());
value = recomputeOrSkip(key);
} Prevention
- Prefer getNullable when absence is a valid business case
- Ensure the producing computation step runs before consumers
- Keep key construction in a single shared helper so producer and consumer agree on keys
When it happens
Trigger: Calling cache.get(key) when no put(key,...) was done for that key in the current computation container; requesting a key whose underlying component/analysis was skipped or deleted; using a different key format than the one used to populate the cache.
Common situations: Plugin or core steps reordered so a consumer step runs before the producer step; a component referenced in a report has no matching DB row, so its cache entry was never written; custom keyspace changes during SonarQube upgrades.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Analysis report %s part %s is missing in database
- Failed to split report for task ${uuid}
- Insufficient privileges
- Insufficient privileges
- Worker count '%s' is invalid. It must be an integer strictly
AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09).
Data as JSON: /api/errors/d54b09b86ec79e05.
Report an issue: GitHub.