justjavac/wechat-miniapp-radar · warning · Error

${payload.error}

Error message

${payload.error}

What it means

Thrown by upstashCommand() in lib/upstash.ts when the REST call returned 2xx but the JSON body carries an `error` field, i.e. Upstash accepted the HTTP request but rejected the command itself. It re-throws that server-supplied message verbatim (so the exact text varies), after the HTTP-status check on the line above has already passed. Like error [6], it only occurs when the integration is configured (otherwise the function returns null early), and callers should catch it and fall back to in-memory.

Source

Thrown at lib/upstash.ts:56

  const config = getUpstashRedisConfig();
  if (!config) return null;

  const response = await fetch(config.url, {
    method: "POST",
    headers: {
      authorization: `Bearer ${config.token}`,
      "content-type": "application/json"
    },
    body: JSON.stringify(command)
  });

  if (!response.ok) {
    throw new Error(`Upstash request failed with ${response.status}`);
  }

  const payload = (await response.json()) as UpstashResponse<T>;
  if (payload.error) {
    throw new Error(payload.error);
  }

  return payload.result ?? null;
}

View on GitHub (pinned to 02a010ecea)

Solutions

  1. Log the exact payload.error string; it names the rejected command or argument and pinpoints the bad call.
  2. Validate the command array shape (Array<string|number>, correct arity for the command) before sending.
  3. For ACL errors, re-scope or regenerate the token in the Upstash dashboard.
  4. Wrap in try-catch and use the in-memory fallback so the feature still works.

Example fix

// before
await upstashCommand(['SET', key]); // missing value -> 'ERR wrong number of arguments'

// after
await upstashCommand(['SET', key, JSON.stringify(value)]);
Defensive patterns

Strategy: try-catch

Validate before calling

function isValidCommand(cmd: Array<string | number>): boolean {
  if (cmd.length === 0 || typeof cmd[0] !== 'string') return false;
  // per-command arity checks, e.g. SET needs >= 3 elements
  if (cmd[0].toUpperCase() === 'SET' && cmd.length < 3) return false;
  return true;
}

Try / catch

try {
  return await upstashCommand<T>(command);
} catch (error) {
  // error.message is the raw Upstash 'error' string
  return inMemoryFallback();
}

Prevention

When it happens

Trigger: Malformed command array (wrong arity, unsupported command name); permission or ACL denial on the token for the requested operation; sending a command the REST proxy does not expose; rate-limit messages sometimes returned as 200 plus an error field instead of 429.

Common situations: Building the command array dynamically and passing wrong types or arity; a read-only token used for a SET; Upstash plan or ACL differences; version drift where a command shape changed.

Related errors


AI-assisted analysis of justjavac/wechat-miniapp-radar@02a010ecea (2026-08-12). Data as JSON: /api/errors/eab5a783c230b276. Report an issue: GitHub.