{"record":{"id":"14064ebb80d42cb8","repo":"sveltejs/kit","slug":"invalid-remote-key-key","errorCode":null,"errorMessage":"Invalid remote key: ${key}","messagePattern":"Invalid remote key: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/shared.js","lineNumber":349,"sourceCode":"}\n\n/**\n * @param {string} id\n * @param {string} payload\n */\nexport function create_remote_key(id, payload) {\n\treturn id + '/' + payload;\n}\n\n/**\n * @param {string} key\n * @returns {{ id: string; payload: string }}\n */\nexport function split_remote_key(key) {\n\tconst i = key.lastIndexOf('/');\n\n\tif (i === -1) {\n\t\tthrow new Error(`Invalid remote key: ${key}`);\n\t}\n\n\treturn {\n\t\tid: key.slice(0, i),\n\t\tpayload: key.slice(i + 1)\n\t};\n}\n","sourceCodeStart":331,"sourceCodeEnd":357,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/shared.js#L331-L357","documentation":"Remote function endpoints address calls with keys of the form `<id>/<payload>`; split_remote_key splits on the last '/'. If the key contains no '/', it is malformed and Kit cannot determine the remote function id, so it throws.","triggerScenarios":"A request arrives at the remote endpoint machinery with a key lacking a '/' — caused by hand-built requests to internal remote endpoints, corrupted/modified query strings, or programmatic callers that pass the wrong string to split_remote_key.","commonSituations":"Custom code or tests invoking internal Kit APIs with a bare id; proxies stripping query parameters; browser extensions rewriting URLs.","solutions":["Fix the caller to pass the full `<id>/<payload>` key produced by Kit's remote-function client","If calling internals directly, append the payload segment (use '/' even when payload is empty)","Inspect request URLs/logs to find who is stripping part of the key","Upgrade Kit if you suspect a routing bug, and open an issue with a repro"],"exampleFix":"// before\nsplit_remote_key('myQuery');\n// after\nsplit_remote_key('src/lib/remote.svelte.js/myQuery/');","handlingStrategy":"validation","validationCode":"const buildRemoteKey = (id, payload = '') => `${id}/${payload}`;\nconst isValidRemoteKey = (key) => typeof key === 'string' && key.includes('/');","typeGuard":"const isRemoteKey = (v) => typeof v === 'string' && v.lastIndexOf('/') !== -1;","tryCatchPattern":"try {\n  const { id, payload } = split_remote_key(key);\n} catch (e) {\n  if (e.message.startsWith('Invalid remote key')) {\n    console.error('Key must be <id>/<payload>:', key);\n  } else throw e;\n}","preventionTips":["Only construct remote keys with Kit's own client APIs","Log full request URLs to catch proxies stripping query segments","Never hand-edit remote-function URLs","Add integration tests that exercise remote endpoints end-to-end"],"tags":["remote-functions","url","internal-api"],"backgroundTag":"invalid-remote-key","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}