{"record":{"id":"7b7a4bcc087e80b1","repo":"sveltejs/kit","slug":"invalid-data-for-map-reviver","errorCode":null,"errorMessage":"Invalid data for Map reviver","messagePattern":"Invalid data for Map reviver","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/shared.js","lineNumber":182,"sourceCode":"\t\t};\n\t}\n\n\tconst all_reducers = { ...encoders, ...remote_fns_reducers };\n\n\t/** @type {(value: unknown) => string} */\n\tconst stringify = (value) => devalue.stringify(value, all_reducers);\n\n\treturn all_reducers;\n}\n\nfunction create_remote_arg_revivers() {\n\tconst remote_fns_revivers = {\n\t\t/** @type {(value: unknown) => unknown} */\n\t\t[remote_object]: (value) => value,\n\t\t/** @type {(value: unknown) => Map<unknown, unknown>} */\n\t\t[remote_map]: (value) => {\n\t\t\tif (!Array.isArray(value)) {\n\t\t\t\tthrow new Error('Invalid data for Map reviver');\n\t\t\t}\n\n\t\t\tconst map = new Map();\n\n\t\t\tfor (const item of value) {\n\t\t\t\tif (\n\t\t\t\t\t!Array.isArray(item) ||\n\t\t\t\t\titem.length !== 2 ||\n\t\t\t\t\ttypeof item[0] !== 'string' ||\n\t\t\t\t\ttypeof item[1] !== 'string'\n\t\t\t\t) {\n\t\t\t\t\tthrow new Error('Invalid data for Map reviver');\n\t\t\t\t}\n\t\t\t\tconst [key, val] = item;\n\t\t\t\tmap.set(parse(key), parse(val));\n\t\t\t}\n\n\t\t\treturn map;","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/shared.js#L164-L200","documentation":"When deserializing remote function arguments, a value tagged as a Map must be an array (of [key, value] string pairs). Anything else — an object, string, or non-array — indicates corrupted or forged payload data, so the reviver throws.","triggerScenarios":"A request payload where the remote_map-tagged value is not an array; hand-crafted or middleware-mutated request bodies; version mismatch between client serializer and server reviver.","commonSituations":"Proxies or test harnesses re-serializing request JSON incorrectly; custom fetch mocks returning reshaped arguments to remote functions.","solutions":["Send Map arguments through the standard remote-function client (don't hand-build request bodies)","Update @sveltejs/kit on client and server so serialization versions match","If testing, mock at the function level rather than reshaping the wire format"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"function isValidMapPayload(v) { return Array.isArray(v); }","typeGuard":"function isMapWireFormat(v) {\n  return Array.isArray(v) && v.every((e) => Array.isArray(e) && e.length === 2 && typeof e[0] === 'string' && typeof e[1] === 'string');\n}","tryCatchPattern":"try {\n  const result = await remoteFn(args);\n} catch (e) {\n  if (e.message.includes('Map reviver')) console.error('Malformed Map argument payload — resend via official client');\n}","preventionTips":["Use the official remote-function client to serialize Maps","Don't hand-craft or mutate remote request bodies","Keep client and server @sveltejs/kit versions in sync"],"tags":["remote-functions","deserialization","security"],"backgroundTag":"invalid-remote-argument-payload","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}