koala73/worldmonitor · error · Error
Redis command error: ${data.error}
Error message
Redis command error: ${data.error} What it means
After a successful HTTP response, getLargeRawJson inspects the Upstash response body's error field and throws 'Redis command error: <detail>' when Upstash accepted the request but the Redis command itself failed. This distinguishes command-level failures (wrong type, OOM, script errors) from HTTP-level problems. Callers should treat it as Redis being unable to serve this key.
Source
Thrown at server/_shared/redis.ts:194
const { sidecarCacheGet } = await import('./sidecar-cache');
return sidecarCacheGet(key);
}
const url = process.env.UPSTASH_REDIS_REST_URL;
const token = process.env.UPSTASH_REDIS_REST_TOKEN;
if (!url || !token) return null;
const resp = await fetch(`${url}/`, {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
'User-Agent': 'worldmonitor-server/1.0 (redis)',
},
body: JSON.stringify(['GET', key]),
signal: AbortSignal.timeout(resolvePipelineTimeoutMs(timeoutMs)),
});
if (!resp.ok) throw new Error(`Redis HTTP ${resp.status}`);
const data = (await resp.json()) as { result?: string | null; error?: string };
if (data.error) throw new Error(`Redis command error: ${data.error}`);
if (!data.result) return null;
return unwrapEnvelope(JSON.parse(data.result)).data;
}
/**
* Read a key's value as a raw Upstash string — no JSON.parse, no envelope unwrap.
* Use when a seeder stores a bare scalar (e.g., a snapshot_id pointer) via
* `['SET', key, bareString]` without JSON.stringify. getCachedJson() on these
* keys silently returns null because JSON.parse throws on unquoted strings,
* and the try/catch swallows the error.
*
* Always uses the raw (unprefixed) key — matches the seed-script write path
* (seeders don't know about the Vercel env-prefix scheme).
*/
export async function getCachedRawString(key: string): Promise<string | null> {
if (process.env.LOCAL_API_MODE === 'tauri-sidecar') {
const { sidecarCacheGet } = await import('./sidecar-cache');
const v = sidecarCacheGet(key);View on GitHub (pinned to 9361220cc0)
Solutions
- Read the detail after the colon: WRONGTYPE means the key's Redis type does not match GET — inspect with TYPE and read via the matching command
- Check what wrote the key; align reader and writer on the same Redis type and envelope format
- Verify database ACLs/permissions allow GET on the key in the Upstash console
- Delete and re-seed the key if its contents are corrupt or from an incompatible schema version
Example fix
// before
const data = await getLargeRawJson('canonical:mil');
// after
let data;
try { data = await getLargeRawJson('canonical:mil'); }
catch (e) {
if (String(e).includes('WRONGTYPE')) await reseedKey('canonical:mil');
else throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Before GET, confirm the key's type matches expectations const type = await getRawKeyType(key); // e.g. via TYPE command if (type !== 'string') reseedOrUseMatchingReader(key, type);
Type guard
function isRedisCommandError(e: unknown): e is Error {
return e instanceof Error && e.message.startsWith('Redis command error:');
} Try / catch
try {
data = await getLargeRawJson(key);
} catch (e) {
if (e instanceof Error && e.message.includes('WRONGTYPE')) {
await reseedKey(key);
data = await getLargeRawJson(key);
} else throw e;
} Prevention
- Keep writer and reader Redis types aligned (string GET vs hash/list commands)
- Audit seed scripts for keys that collide with JSON-string keys
- Check Upstash ACLs allow the commands your code issues
- Include the key name in the thrown error context for faster diagnosis
When it happens
Trigger: Upstash returns 200 with { error: ... }, e.g. WRONGTYPE because the key holds a non-string value, an OOM/permission denial, or a malformed command — any body-level error string returned by the REST API for GET key.
Common situations: A key written by another code path as a hash/list/set but read here as a string (WRONGTYPE); a seed script wrote a different envelope; Upstash database rules or ACLs denying the command; corrupted key data after manual flush/import.
Related errors
- Redis EVAL failed: ${data.error}
- Failed to enqueue scenario job
- Redis not configured
- Redis HTTP ${resp.status}
- Redis EVAL returned an invalid response
AI-assisted analysis of koala73/worldmonitor@9361220cc0 (2026-09-01).
Data as JSON: /api/errors/c114d70ddccd99a2.
Report an issue: GitHub.