{"record":{"id":"eab5a783c230b276","repo":"justjavac/wechat-miniapp-radar","slug":"payload-error","errorCode":null,"errorMessage":"${payload.error}","messagePattern":"\\$\\{payload\\.error\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/upstash.ts","lineNumber":56,"sourceCode":"  const config = getUpstashRedisConfig();\n  if (!config) return null;\n\n  const response = await fetch(config.url, {\n    method: \"POST\",\n    headers: {\n      authorization: `Bearer ${config.token}`,\n      \"content-type\": \"application/json\"\n    },\n    body: JSON.stringify(command)\n  });\n\n  if (!response.ok) {\n    throw new Error(`Upstash request failed with ${response.status}`);\n  }\n\n  const payload = (await response.json()) as UpstashResponse<T>;\n  if (payload.error) {\n    throw new Error(payload.error);\n  }\n\n  return payload.result ?? null;\n}\n","sourceCodeStart":38,"sourceCodeEnd":61,"githubUrl":"https://github.com/justjavac/wechat-miniapp-radar/blob/02a010ecea0320b7aa975bb62a5dde271ae630c9/lib/upstash.ts#L38-L61","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Log the exact payload.error string; it names the rejected command or argument and pinpoints the bad call.","Validate the command array shape (Array<string|number>, correct arity for the command) before sending.","For ACL errors, re-scope or regenerate the token in the Upstash dashboard.","Wrap in try-catch and use the in-memory fallback so the feature still works."],"exampleFix":"// before\nawait upstashCommand(['SET', key]); // missing value -> 'ERR wrong number of arguments'\n\n// after\nawait upstashCommand(['SET', key, JSON.stringify(value)]);","handlingStrategy":"try-catch","validationCode":"function isValidCommand(cmd: Array<string | number>): boolean {\n  if (cmd.length === 0 || typeof cmd[0] !== 'string') return false;\n  // per-command arity checks, e.g. SET needs >= 3 elements\n  if (cmd[0].toUpperCase() === 'SET' && cmd.length < 3) return false;\n  return true;\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await upstashCommand<T>(command);\n} catch (error) {\n  // error.message is the raw Upstash 'error' string\n  return inMemoryFallback();\n}","preventionTips":["Centralize command construction in one helper so arity/type mistakes surface in one place.","Always pair upstashCommand with an in-memory fallback at the call site.","Pre-validate dynamic command arrays (command name plus arity) before sending."],"tags":["redis","upstash","command-error"],"backgroundTag":null,"analyzedSha":"02a010ecea0320b7aa975bb62a5dde271ae630c9","analyzedAt":"2026-08-12T16:16:33.227Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}