koala73/worldmonitor · error · Error

Resilience indicator response cache returned no data

Error message

Resilience indicator response cache returned no data

What it means

Thrown in createGetResilienceIndicators (get-resilience-indicators.ts) when the layered responseCache() wrapper resolves to null/undefined even though a buildResponse fallback was supplied. The code builds a composite cache key (schema version + construct selections) and expects the cache helper to either return a cached response or the freshly built one; a null result means the cache layer could neither read nor safely store the response, so the handler refuses to return an empty/undefined payload.

Source

Thrown at server/worldmonitor/resilience/v1/get-resilience-indicators.ts:336

        scores,
        materializeIndicatorTrace(trace, scores),
        { now: now(), dataVersion },
      );
    };

    if (!responseCache) return buildResponse();
    const constructs = getConstructVersions();
    const cacheKey = [
      'resilience:indicator-trace:v1',
      countryCode,
      getCurrentCacheFormula(),
      RESILIENCE_SCHEMA_V2_ENABLED ? 'schema-v2' : 'schema-v1',
      `energy-${constructs.energy}`,
      `education-${constructs.education}`,
      `financial-system-${constructs.financialSystemExposure}`,
    ].join(':');
    const cached = await responseCache(cacheKey, buildResponse);
    if (cached == null) throw new Error('Resilience indicator response cache returned no data');
    return cached;
  };
}

export const getResilienceIndicators = createGetResilienceIndicators();

View on GitHub (pinned to 9361220cc0)

Solutions

  1. Check cache backend health and credentials; the cache layer failing both read and write is the usual root cause.
  2. Verify dependencies.responseCache is wired to the real cachedFetchJson-based helper in this deployment, not a stub that returns null.
  3. Inspect buildResponse: it must always resolve to a valid GetResilienceIndicatorsResponse; fix any path where it returns null.
  4. Retry after the transient cache outage, or add a direct fallback that calls buildResponse() when the cache layer returns null.

Example fix

// before
const cached = await responseCache(cacheKey, buildResponse);
if (cached == null) throw new Error('Resilience indicator response cache returned no data');
// after
let cached = await responseCache(cacheKey, buildResponse);
if (cached == null) {
  console.warn(`response cache returned no data for ${cacheKey}; building directly`);
  cached = await buildResponse();
}
if (cached == null) throw new Error('Resilience indicator response cache returned no data');
Defensive patterns

Strategy: fallback

Validate before calling

// before the call, confirm cache dependency is wired
if (!dependencies.responseCache) console.warn('responseCache missing; null results likely');

Type guard

function isIndicatorsResponse(v: unknown): v is GetResilienceIndicatorsResponse {
  return typeof v === 'object' && v !== null && 'countryCode' in v && Array.isArray((v as any).indicators);
}

Try / catch

try {
  return await getResilienceIndicators(req);
} catch (err) {
  if (err.message === 'Resilience indicator response cache returned no data') {
    return buildIndicatorsDirectly(req); // bypass cache layer
  }
  throw err;
}

Prevention

When it happens

Trigger: Calling getResilienceIndicators when responseCache(cacheKey, buildResponse) returns null — e.g., the cache backend errors on both GET and SET, buildResponse itself returns null, or the cache helper is misconfigured/absent (dependencies.responseCache undefined paths handled above this line) yet a null still slips through.

Common situations: 1) Redis/Upstash outage combined with a buildResponse that fails and returns null; 2) cache helper returning null on serialization failures of a large schema-v2 payload; 3) wiring mistake in dependencies that passes a broken responseCache stub in tests or preview environments.

Related errors


AI-assisted analysis of koala73/worldmonitor@9361220cc0 (2026-09-01). Data as JSON: /api/errors/c17bf481c0c01fa1. Report an issue: GitHub.