{"record":{"id":"65b307275f19b457","repo":"sveltejs/kit","slug":"cannot-used-reserved-query-parameter-invalidate","errorCode":null,"errorMessage":"Cannot used reserved query parameter \"${INVALIDATED_PARAM}\"","messagePattern":"Cannot used reserved query parameter \"(.+?)\"","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/client/client.js","lineNumber":3676,"sourceCode":"\t\tresult.props.page.state = history_metadata?.persistState ? parse(history_metadata.state) : {};\n\t}\n\n\tawait initialize(result, target, should_hydrate);\n}\n\n/**\n * @param {URL} url\n * @param {boolean[]} invalid\n * @returns {Promise<import('types').ServerNodesResponse | import('types').ServerRedirectNode>}\n */\nasync function load_data(url, invalid) {\n\tconst data_url = new URL(url);\n\tdata_url.pathname = add_data_suffix(url.pathname);\n\tif (url.pathname.endsWith('/')) {\n\t\tdata_url.searchParams.append(TRAILING_SLASH_PARAM, '1');\n\t}\n\tif (DEV && url.searchParams.has(INVALIDATED_PARAM)) {\n\t\tthrow new Error(`Cannot used reserved query parameter \"${INVALIDATED_PARAM}\"`);\n\t}\n\tdata_url.searchParams.append(INVALIDATED_PARAM, invalid.map((i) => (i ? '1' : '0')).join(''));\n\n\t// use window.fetch directly to allow using a 3rd party-patched fetch implementation\n\tconst fetcher = DEV ? dev_fetch : window.fetch;\n\tconst res = await fetcher(data_url.href, {});\n\n\t// detect new deployments from the response header\n\tnotify_version(res.headers.get('x-sveltekit-version'));\n\n\tif (!res.ok) {\n\t\t// if `__data.json` doesn't exist or the server has an internal error,\n\t\t// avoid parsing the HTML error page as a JSON\n\t\t/** @type {App.Error} */\n\t\tlet error = { status: res.status, message: 'Internal Error' };\n\n\t\tif (res.headers.get('content-type')?.includes('application/json')) {\n\t\t\terror = { status: res.status, ...(await res.json()) };","sourceCodeStart":3658,"sourceCodeEnd":3694,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/client/client.js#L3658-L3694","documentation":"When the client fetches data it appends a reserved query parameter (__invalidated or similar INVALIDATED_PARAM) to communicate which stores need invalidation. If the developer's own URL already contains that parameter, appending it would corrupt the request, so DEV throws. This only guards the dev experience; it indicates the app is colliding with an internal protocol detail.","triggerScenarios":"goto('/page?__invalidated=...') or navigating with a hand-built URL containing the reserved key; persisting a data-request URL (with the param) and re-navigating to it.","commonSituations":"Replaying URLs captured from network tab data-suffix requests; caching full request URLs including internal params; naming custom query params identically to the internal one.","solutions":["Remove the reserved parameter from URLs before passing to goto/fetch navigation","Never persist/replay URLs taken from SvelteKit __data requests","Rename your own query parameter if it collides with the internal key"],"exampleFix":"// before\nconst target = new URL(savedUrl); // contains ?__invalidated=1\nawait goto(target.href);\n// after\nconst target = new URL(savedUrl);\ntarget.searchParams.delete('__invalidated');\nawait goto(target.href);","handlingStrategy":"validation","validationCode":"const RESERVED = '__invalidated'; // internal INVALIDATED_PARAM\nfunction stripReservedParams(u) {\n  const url = new URL(u, location.href);\n  url.searchParams.delete(RESERVED);\n  return url;\n}\nawait goto(stripReservedParams(savedUrl).href);","typeGuard":null,"tryCatchPattern":"try { await goto(url); } catch (e) { if (e.message.includes('reserved query parameter')) { const u = new URL(url, location.href); [...u.searchParams.keys()].forEach((k) => { if (k.startsWith('__')) u.searchParams.delete(k); }); await goto(u.href); } else { throw e; } }","preventionTips":["Never reuse URLs captured from __data network requests","Avoid query params starting with double underscores","Sanitize persisted deep-link URLs before navigation"],"tags":["query-parameters","routing","reserved-parameter"],"backgroundTag":"reserved-query-param","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}